RE: [PHP-DB] Help! Can't "select" db after uploading file from mu lti-part form
| From: | CJ Romberger | Date: | Mon, 19 Jun 2000 19:15:02 +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-492@lists.php.net to get a copy of this message | ||
The "action" is covered in the lower part of the form, in the input types.
I know it's working right because it executes the correct piece of code,
based on the "action" chosen. I've also tried, though, putting the file name
in the top FORM....METHOD...ACTION="upload_test.php3"> and tried sending it
different values of submit. Same problem.
Here's how just the form part looks without all the slashes in it so you can
see it better:
<HTML>
<FORM ENCTYPE="multipart/form-data" METHOD=POST>
<INPUT TYPE="SUBMIT" name="action" value="New Entry">
<INPUT TYPE="SUBMIT" name ="action" value ="Overview">
Search: <INPUT type="text" name="word">
<INPUT TYPE="SUBMIT" name ="action" value="Search">
CSV import: <INPUT TYPE="file" name="csvfile\">
<input type="SUBMIT" name="action" value="CSV
Import"><BR><BR>
</form>
</HTML>
What happens to it depends on which button you choose.
I tried the thing that Rasmus had mentioned (had the wrong link in the $sql
part), but that didn't change anything. It's erroring on the
mysql_select_db line and nothing after that is executing. I'm just hoping
he or someone else sees something else I've done wrong. I've tried
everything I can think of. I'm stuckola in the mud.
Thanx for helping!!
CJ
"No other personal quality contributes to success more than relentless
persistence in the pursuit of one's goals."
-----Original Message-----
From: Andrew Sheh [mailto:ashea@dmetechnologies.com]
Sent: Monday, June 19, 2000 2:07 PM
To: CJ Romberger
Subject: RE: [PHP-DB] Help! Can't "select" db after uploading file from
multi-part form
where is your form going to? You might need to fill in the ACTION="" in
the FORM TAG, plus the things Rasmus mentioned.
andrew
> -----Original Message-----
> From: CJ Romberger [mailto:cjrom@rx.com]
> Sent: Monday, June 19, 2000 9:05 AM
> To: 'Rasmus Lerdorf'; CJ Romberger
> Cc: php-db@lists.php.net
> Subject: RE: [PHP-DB] Help! Can't "select" db after uploading file from
> multi-part form
>
>
> 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
> \">
>
> <INPUT TYPE=\"SUBMIT\" name = \"action\" value = \" Overview
> \">
>
> Search: <INPUT type=\"text\" name = \"word\">
> <INPUT TYPE=\"SUBMIT\" name = \"action\" value = \" Search
> \">
> 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
>
> --
> 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
>