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




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




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

2002-08-29 Thread Michael Knauf

I'm in OS X 10.2 (Jaguar) Apache/PHP/MySQL are all playing happily 
together, so it's time to get some work done. From the MySQL client, 
this query does what I expect it to:

update endpage set productname='Berenice lamp', bgcolor='eec472', 
imgsrc='bereniceep.jpg', img_orientation='horizontal', cartlink='I 
don\'t know yet', categorylink='lighting.html', catlinkimg='sex', 
copy=' Since it was designed in 1985, the Berenice lamp has become a 
classic, acquired by museums everywhere. Paolo Rizzatto and Alberto 
Meda gave it a fully articulated and adjustable arm on a weighted 
base either wall-mounted, clip-on or free standing. Finish colors may 
be matte black or silver with green, blue, black, or silver diffuser 
shade. Its 35-watt halogen bulb provides excellent task lighting in a 
355-degree arc. The transformer is separated from the base, making 
Berenice perfect for tight spaces. ', price='320', 
titleimg='berenicetitle.gif' where id='5'

Now, I got that query by doing an  into an html page 
and copying and pasting into the MySQL client, where the query 
returns the expected result...

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);

Can anybody explain that?

Michael

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