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

From: Date: Mon, 19 Jun 2000 16:05:24 +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-488@lists.php.net to get a copy of this message
I am totally able to accept that I'm doing something stupid! I just can't figure out what! Here's the whole darn thing: <?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/xxxxxx/www/address_book"; $newfilename = $newfilepath . $csvfile; copy($csvfile, $newfilename); $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); 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; } ?> ************THAT'S THE END OF IT CJ -----Original Message----- From: Rasmus Lerdorf [mailto:rasmus@php.net] Sent: Monday, June 19, 2000 10:56 AM To: CJ Romberger Cc: php-db@lists.php.net Subject: Re: [PHP-DB] Help! Can't "select" db after uploading file from multi-part form There is no correlation. You are doing something stupid. You would need to show the relevant parts of your code for us to have any shot at figuring out what you are doing wrong. -Rasmus On Mon, 19 Jun 2000, CJ Romberger wrote: > I sent an email about this a few days ago, but I'm still totally stuck and > really need some help! > > If I upload a file from a multipart form, I then cannot select a database in > mySQL! I don't understand the correlation here or what to do about it. > I've tried putting them in separate functions, and that doesn't help. > > I can connect/select/query if I don't try to upload. > I can upload and copy, but then cannot connect/select/query. > > HELP! > > Here is the error I get: > Warning: 1 is not a MySQL link index in > /home/eboing/eboing-www/address_book/upload_test_3.php3 on line 35 > cannot select > > ANY ideas??? > > CJ Romberger > cj@romberger.com > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#488) next »