[thelist] mySQL/PHP - INSERT not working

Mr. Tenuta dtportnoy at videotron.ca
Thu Jun 17 09:52:50 CDT 2004


I'm not used to seeing an include like that, hehe new to me.
Syntax i've seen and use is:

include("inc/config.php"); // maybe its not reading your config.php because
of that?

Your $_POST's seem fine and as you said they return the values. There is an
extra parameter in the mysql_query also. I've seen some people use it
without as you have done and still work, other times it would not work
without the other paramater. In your config.php make sure to set your
connection to a variable.

Ex in config.php:

$link = mysql_connect("localhost", "username", "password");  // just making
sure that's how you have it
mysql_select_db("dbname", $link); // choose DB once connected ($link)

So I'm guessing your config.php looks somewhat similar to that.
Here's the mysql_query with the added parameter.

mysql_query("INSERT INTO scouting(playerID, report) VALUES('" . $pid ."','"
. $scout ."')", $link);

I don't know if it makes a difference but I usually don't leave a space
between  open brackets.
Ex:         You put ----- scouting (playerID....
               I would put - scouting(playerID...
Same thing with VALUES(

Also for extra prevention i'd concatonate the variable in the VALUES instead
of putting them in string query directly as I did above.

Notice that there is a single quote then a double quote, not jsut a double
quote, I will write it with spaces just to emphasize, but don't actually use
the spaces in the query... VALUES(' " . $pid . " ',' " . $scout . " ')"  //
end of query.

Hope something in there solves your probem :) I know how fussy query string
can be :P
Oh and also, make sure your column names are typed right, hehe i get alot of
error with case sensitivity.
Ex. I tend to put PlayerId when the actual name is PlayerID.


----- Original Message ----- 
From: "Tom Dell'Aringa" <pixelmech at yahoo.com>
To: <thelist at lists.evolt.org>
Sent: Thursday, June 17, 2004 10:18 AM
Subject: [thelist] mySQL/PHP - INSERT not working

> Little help please, I have this INSERT:
> include 'inc/config.php'; // config contains my DB connection
> $scout = $_POST['scoutReport'];
> $pid   = $_POST['pid'];
> mysql_query("INSERT INTO scouting (playerID, report) VALUES
> I've printed out the values for the POST variables and they are coming
over. I can run the insert
> successfully in mySQL and it works. But it won't work in my php page - am
I forgetting something?
> It's been awhile...
> Thanks
> 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