RE: [PHP-DB] Help! Can't "select" db after uploading file from mu lti-part form

From: Date: Mon, 19 Jun 2000 16:18:49 +0000
Subject: RE: [PHP-DB] Help! Can't "select" db after uploading file from mu lti-part form
Groups: php.db 
Request: Send a blank email to php-db+get-491@lists.php.net to get a copy of this message
I might have that wrong, but changing it didn't fix the problem. Matter of fact, I commented out all the db stuff (except the close) after the select part, and it's still giving me the same error. I'm recopying the program here with the commented-out piece in it. (I do actually have a username and password in there, along with a directory name where the xxxx's are. I just have to keep the private information out of my code piece here.) Thanx for looking at this! CJ <?php function display_menu() { echo " <HTML> <FORM ENCTYPE=\"multipart/form-data\" METHOD=POST> <INPUT TYPE=\"SUBMIT\" name = \"action\" value = \"New Entry \"> &nbsp; <INPUT TYPE=\"SUBMIT\" name = \"action\" value = \" Overview \"> &nbsp; Search: <INPUT type=\"text\" name = \"word\"> <INPUT TYPE=\"SUBMIT\" name = \"action\" value = \" Search \"> &nbsp; CSV import: <INPUT TYPE=\"file\" name = \"csvfile\"> <input type=\"SUBMIT\" name=\"action\" value= \" CSV Import \"><BR><BR> </form> </HTML>"; } ?> <?php function action_csv_import($csvfile) { $newfilepath = "/home/xxxxx/www/address_book"; $newfilename = $newfilepath . $csvfile; copy($csvfile, $newfilename); $connect = mysql_connect("localhost", "username", "password") || die ("cannot connect"); $db = mysql_select_db("mydatabasename", $connect) || die("cannot select"); // $sql = "Select * from address_book"; // $result = mysql_query($sql, $connect); // while($myrow = mysql_fetch_array($result)) { // echo "here is a row<br>"; // $id = $myrow["id"]; // echo "$id<br>"; // } mysql_close(); // This part doesn't do anything at the moment. $fp = fopen($csvfile, "r"); fclose($fp); } ?> <?php // This is the main part of the program. display_menu(); $action = strtolower(trim($action)); echo $action . "<br>"; switch($action) { case "csv import": action_csv_import($csvfile); break; } ?> ~ CJ "I'm like a mosquito in a nudist colony....I know what to do...I just don't know where to start." ...don't know who's quote this was, but it sure is funny! -----Original Message----- From: Rasmus Lerdorf [mailto:rasmus@php.net] Sent: Monday, June 19, 2000 11:16 AM To: CJ Romberger Cc: php-db@lists.php.net Subject: RE: [PHP-DB] Help! Can't "select" db after uploading file from mu lti-part form > $connect = mysql_connect("localhost", "myusername", > "mypassword") || > die ("cannot connect"); > $db = mysql_select_db("mydatabasename", $connect) || die("cannot > select"); > $sql = "Select * from address_book"; > $result = mysql_query($sql, $db); This is bogus. The second argument to mysql_query() is a link identifier. In your case that would be $connect. -Rasmus

« previous php.db (#491) next »