RE: [PHP] why does my querry work in the mysql client but not in php?
| From: | Jay Blanchard | Date: | Thu, 29 Aug 2002 11:40:22 +0000 |
| Subject: | RE: [PHP] why does my querry work in the mysql client but not in php? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-114499@lists.php.net to get a copy of this message | ||
[snip]
from the php page however, it does not work, even though it appears
to be generating a perfectly good querry... Here's the PHP
$connection = mysql_connect("server", "user", "pass") or
die("Couldn't connect.");
$db = mysql_select_db($db_name, $connection) or die("Couldn't select
database.");
$query = "update endpage set productname='$productname',
bgcolor='$bgcolor', imgsrc='$imgsrc',
img_orientation='$img_orientation', cartlink='$cartlink',
categorylink='$categorylink', catlinkimg='$catlinkimg', copy='$copy',
price='$price', titleimg='$titleimg' where id='$id'";
$result = mysql_query($query);
[/snip]
1. Do a print($query); so that you can look at the query and make sure that
it is right.
2. Trap MySQL errors for the query by doing something like this;
if(!($result = mysql_query($query, ))){
print("MySQL reports: " . mysql_error . "\n");
exit();
}
WHERE IS YOUR DB CONNECTION VARIABLE?
I believe that your error is that the following line
$result = mysql_query($query);
should be
$result = mysql_query($query, $connection);
HTH!
Jay
*****************************************************
* Texas PHP Developers Conf Spring 2003 *
* T Bar M Resort & Conference Center *
* New Braunfels, Texas *
* Contact jay.blanchard@niicommunications.com *
* *
* Want to present a paper or workshop? Contact now! *
*****************************************************