Can anyone take a look at my code to see why the mysql components are being ignored? ------------------------------------------------------------------------------------------------------------------------------- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Listing 13.1 Opening a Connection to a Database</title> </head> <body> <?php global $strDesc; global $fileUpload; global $fileUpload_name; global $fileUpload_size; global $fileUpload_type; if ( ! empty( $_REQUEST['strDesc'] )&& ! empty( $_REQUEST['fileUpload'] ) ){ // check user input here! $dberror = ""; $ret = add_to_database( $_REQUEST['strDesc'], $_REQUEST['fileUpload'], $_REQUEST['fileUpload_type'], $_REQUEST['fileUpload_name'], $_REQUEST['fileUpload_size'], $dberror ); if ( ! $ret ) { print "Error: $dberror<br />\n"; } else { echo "<h1>File Uploaded</h1>"; echo "The details of the uploaded file are shown below:<br><br>"; echo "<b>File name:</b> $fileUpload_name <br>"; echo "<b>File type:</b> $fileUpload_type <br>"; echo "<b>File size:</b> $fileUpload_size <br>"; echo "<b>Uploaded to:</b> $fileUpload <br><br>"; echo "<a href='uploadfile.php'>Add Another File</a>"; } } else { write_form(); } function add_to_database( $strDesc, $fileUpload, $fileUpload_name, $fileUpload_size, $fileUpload_type, &$dberror ) { $strDesc = mysql_real_escape_string( $strDesc ); $fileUpload = mysql_real_escape_string( $fileUpload ); $fileUpload_name = mysql_real_escape_string( $fileUpload_name ); $fileUpload_size = mysql_real_escape_string( $fileUpload_size ); $fileUpload_type = mysql_real_escape_string( $fileUpload_type ); $fileHandle = fopen($fileUpload, "r"); $fileContent = fread($fileHandle, $fileUpload_size); $fileContent = addslashes($fileContent); $link = mysql_pconnect( "localhost", "", "" ); if ( ! $link ) { $dberror = mysql_error(); return false; } if ( ! mysql_select_db( "myfiles", $link ) ) { $dberror = mysql_error(); return false; } $query = "INSERT INTO myblobs( strDesc, fileUpload, fileUpload_name, fileUpload_size, fileUpload_type ) values('$strDesc', '$fileUpload', '$fileUpload_name', '$fileUpload_size', '$fileUpload_type' )"; if ( ! mysql_query( $query, $link ) ) { $dberror = mysql_error(); return false; } return true; } function write_form() { print ' <form method="post" enctype="multipart/form-data" name="frmUploadFile" action="' . $_SERVER['PHP_SELF'] . '"> <p><input type="text" name="strDesc" size="20" maxlength="50" /> file Description:</p> <p><input type="file" name="fileUpload" size="20" /> Choose a file</p> <input type="submit" value="Upload this file" name="Submit" /></p> </form> </FORM> '; } ?> </form> </BODY> </HTML> Patrick Roane Web design and development www.franklin-band.com Fox River Grove, Il.