[PHP] Why doesn't the second instance work?

2002-09-02 Thread Michael Knauf


I'm creating a list/menu form item and populating it from a database,=20
the code snippet looks like this:
=00
Edit an item:
";
echo "";
for ($i=3D0; $i <$num_results; $i++)
{
$row =3D mysql_fetch_array($result);
echo " $row[id], =
$row[productname]";
}
echo "";
echo "";
echo "";
?>=00=00

Everything is good, Everything is fine, so I decide to put the same=20
snippet of code in again, this time pointing to a different page -- 
One=20=

page lets you edit the fields, the other shows you the final output,=20
the item from the database featured on a web page.

preview an endpage:

";
echo "";
for ($i=3D0; $i <$num_results; $i++)
{
$row =3D mysql_fetch_array($result);
echo " $row[id], =
$row[productname]";
}
echo "";
echo "";
echo "";
?>=00=00

The second instance does not work, I get a select with "," as each=20
option, no population with the id or productname. Clearly, I don't=20
understand something here, can anyone tell me what?

Thanks for the time,

Michael


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