RE: [PHP] why does my querry work in the mysql client but not in php?

2002-08-29 Thread Jay Blanchard

[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 [EMAIL PROTECTED]   *
*   *
* Want to present a paper or workshop? Contact now! *
*



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] why does my querry work in the mysql client but not in php?

2002-08-29 Thread Jay Blanchard

[snip]
2. Trap MySQL errors for the query by doing something like this;

if(!($result = mysql_query($query, ))){
   print(MySQL reports:  . mysql_error . \n);
   exit();
}
[/snip]

TYPO!!! :^] Should be mysql_error() (note the parentheses)

HTH!

Jay

*
* Texas PHP Developers Conf  Spring 2003*
* T Bar M Resort  Conference Center*
* New Braunfels, Texas  *
* Contact [EMAIL PROTECTED]   *
*   *
* Want to present a paper or workshop? Contact now! *
*




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php