468,247 Members | 1,328 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,247 developers. It's quick & easy.

$sql = "update products set smallpicname = $myfile .....????

hi, i have this
$sql = "update products set smallpicname = $myfile where id=37";
mysql_query($sql);
i want the value of $myfile to be in the $sql , but it is not doing it, so
what am i doing wrong?
how can i put variables in the $sql statement so i can execute it with
mysql_query ???
since i want also to put .....id= $idvar please help
Feb 2 '06 #1
8 1540
$sql = "update products set smallpicname = ".$myfile." where
id=".$idvar;

Feb 2 '06 #2
i tried that it did not work.
i know that the value is in the $myfile since i tested it using echo.

"Antonino Tumminelli" <my*****@web.de> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
$sql = "update products set smallpicname = ".$myfile." where
id=".$idvar;

Feb 2 '06 #3
Jon
Try $sql = "UPDATE products SET smallpicname = '$myfile' WHERE id=37"; -
you're missing the single quotes for string data (which I assume
smallpicname is).

To do the id=idvar it'd be "UPDATE products SET id=$idvar, smallpicname =
'$myfile' WHERE id=37";

"Jim S." <ji*@yeah.com> wrote in message
news:1h*****************@newsread1.news.atl.earthl ink.net...
hi, i have this
$sql = "update products set smallpicname = $myfile where id=37";
mysql_query($sql);
i want the value of $myfile to be in the $sql , but it is not doing it, so
what am i doing wrong?
how can i put variables in the $sql statement so i can execute it with
mysql_query ???
since i want also to put .....id= $idvar please help

Feb 2 '06 #4
Be sure to escape any values that are in your queryt, e.g:
$myfile = mysql_real_escape_string($myfile);
$sql = "update products set smallpicname ='$myfile' where id='$idvar'";

Feb 2 '06 #5
smallpicname is the field name in the table, and $myfile is the variable
that holds the value.
i tried your suggestion and it did not work. (sorry, any other ... what am i
doing wrong) i know everything is right since if i change $myfile with
\'hello\' the value get stored where it supposed to.

thanks again guys and gals
jim

"Jon" <jo***@netins.com> wrote in message
news:dr*********@news.netins.net...
Try $sql = "UPDATE products SET smallpicname = '$myfile' WHERE id=37"; -
you're missing the single quotes for string data (which I assume
smallpicname is).

To do the id=idvar it'd be "UPDATE products SET id=$idvar, smallpicname =
'$myfile' WHERE id=37";

"Jim S." <ji*@yeah.com> wrote in message
news:1h*****************@newsread1.news.atl.earthl ink.net...
hi, i have this
$sql = "update products set smallpicname = $myfile where id=37";
mysql_query($sql);
i want the value of $myfile to be in the $sql , but it is not doing it,
so
what am i doing wrong?
how can i put variables in the $sql statement so i can execute it with
mysql_query ???
since i want also to put .....id= $idvar please help


Feb 3 '06 #6
try this
$sql = "UPDATE products SET smallpicname='".$myfile."'.....";

Should work.

Cheers,
Ivan

Jim S. wrote:
smallpicname is the field name in the table, and $myfile is the variable
that holds the value.
i tried your suggestion and it did not work. (sorry, any other ... what am i
doing wrong) i know everything is right since if i change $myfile with
\'hello\' the value get stored where it supposed to.

thanks again guys and gals
jim

"Jon" <jo***@netins.com> wrote in message
news:dr*********@news.netins.net...
Try $sql = "UPDATE products SET smallpicname = '$myfile' WHERE id=37"; -
you're missing the single quotes for string data (which I assume
smallpicname is).

To do the id=idvar it'd be "UPDATE products SET id=$idvar, smallpicname =
'$myfile' WHERE id=37";

"Jim S." <ji*@yeah.com> wrote in message
news:1h*****************@newsread1.news.atl.earthl ink.net...
hi, i have this
$sql = "update products set smallpicname = $myfile where id=37";
mysql_query($sql);
i want the value of $myfile to be in the $sql , but it is not doing it,
so
what am i doing wrong?
how can i put variables in the $sql statement so i can execute it with
mysql_query ???
since i want also to put .....id= $idvar please help



Feb 3 '06 #7

"Antonino Tumminelli" <my*****@web.de> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
$sql = "update products set smallpicname = ".$myfile." where
id=".$idvar;
that's not the problem. he should be putting quotes around the string. the
variables will expand just fine.
$sql = "UPDATE products SET smallpicname = '$myfile' WHERE id=$idvar";
it's good practice (just for visual debugging) to put SQL keywords in caps.

Feb 13 '06 #8

<ce*****@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Be sure to escape any values that are in your queryt, e.g:
$myfile = mysql_real_escape_string($myfile);
$sql = "update products set smallpicname ='$myfile' where id='$idvar'";
$sql = "update products set smallpicname ='$myfile' where id=$idvar";
it's not good SQL etiquette to put a number in a quotes unless the columns
is defines as some CHAR type.

Feb 13 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Dave | last post: by
3 posts views Thread by Terry Olsen | last post: by
6 posts views Thread by '~=_Slawek_=~' | last post: by
5 posts views Thread by Stephen Plotnick | last post: by
6 posts views Thread by Nano | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.