473,401 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

$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 1667
$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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a...
2
by: Mike | last post by:
Given table a: col1 col2 name1 name2 where col1 and col2 make up the unique key. Given a stage table b: col1 col2 name1 name2. (again unique key same as a) table a has 34M rows table b has 2...
1
by: vj | last post by:
How to Update multiple tables in a single SQL update Statement? Is there any way out? vj.
3
by: -Michelle- | last post by:
Hi Using A2003 on XP I am wondering from the MVP's and others, what is the most efficient way (in terms of time to process) of updating data in a table, using the docmd.RunSQL or Recordset ...
3
by: Terry Olsen | last post by:
I've got 2 different web pages, both updating the same SQL database. One is for the Technician and one is for the Manager. The technician's update page works fine but the Manager's update page...
0
by: fatmosh | last post by:
I have a GridView that is pulling data from a SQL database using a Select command. I would like to use GridView's built-in "Edit, Update, Cancel" functionality because it is very handy. However,...
6
by: '~=_Slawek_=~' | last post by:
I have problem with SQL update. Sometimes it can take 2-10 seconds. I need to make this update every time page is opened - ASYNCHRONOUSLY. I have read forums, php.net etc about running php code...
5
by: Stephen Plotnick | last post by:
I'm very new to VB.NET 2003 Here is what I have accomplished: MainSelectForm - Selects an item In a public class I pass a DataViewRow to ItemInformation1 Form ItemInformation2 Form
6
by: Nano | last post by:
I want to update a MS Access Table using ASP, I have made the connection with the database but I am unable to update it. I am using the following code: ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.