[thelist] mySQL/PHP - INSERT not working [UPDATED]
Mr. Tenuta
dtportnoy at videotron.ca
Thu Jun 17 11:13:22 CDT 2004
Looks like you missed the line I posted. You need to specify the db name
right after you connect using mysql_connect. Here's the line.
mysql_select_db("dbname", $conn); // choose DB once connected
($conn)
Thanks for the heads up on those php facts, i'm still quite new, but this
mailing list is amazing and full of knowledge! Best of luck,
Lawrence
----- Original Message -----
From: "Tom Dell'Aringa" <pixelmech at yahoo.com>
To: <thelist at lists.evolt.org>
Sent: Thursday, June 17, 2004 11:42 AM
Subject: Re: [thelist] mySQL/PHP - INSERT not working [UPDATED]
> Okay, I adjusted the code as follows:
>
> ---------
> $conn = mysql_connect($hostname, $dbusername, $dbpassword);
> if (!$conn) {
> die('Could not connect: ' . mysql_error());
> }
>
> $scout = $_POST['scoutReport'];
> $pid = $_POST['pid'];
> $result = mysql_query("INSERT INTO scouting (playerID, report) VALUES ('"
. $pid ."','" . $scout .
> "')", $conn);
>
> if (!$result) {
> die('Invalid query: ' . mysql_error());
> }
> -----------
>
> And I'm getting the following error:
>
> Invalid query: No Database Selected
>
> How can that be if $conn didn't fail? Do I somewhere have to specify the
name of the DB?
>
> Tom
>
> =====
> http://www.Pixelmech.com/ - read my latest blog posting!
>
> John 3:16
>
>
>
> --
> * * Please support the community that supports you. * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>
More information about the thelist
mailing list