Solved

update query

Posted on 2011-03-09
4
364 Views
Last Modified: 2012-06-22
hi am unsure whats wrong with this UPDATE query thanks for helping :


CREATE TABLE IF NOT EXISTS `images` (
  `pictureId` int(4) NOT NULL auto_increment,
  `memberId` int(11) default NULL,
  `imgLarge` varchar(255) default NULL,
  `imgSmall` varchar(255) default NULL,
  PRIMARY KEY  (`pictureId`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

$sqlUpdate = "UPDATE `images` SET `imgLarge` = '".$file."', `imgSmall` = '".$save."' WHERE `pictureId` = '".$pictureId."'";

thank you for helping
0
Comment
Question by:helpchrisplz
4 Comments
 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 500 total points
ID: 35086050
The query is fine as long as

a)  you actually have a database connection in place,

and

b) the variables  $file, $save and $pictureId have meaningful values. Try running this

$sqlUpdate = "UPDATE `images` SET `imgLarge` = '".$file."', `imgSmall` = '".$save."' WHERE `pictureId` = '".$pictureId."'";
echo $sqlUpdate;

mysql_query( $sqlUpdate ) or die( mysql_error() );

Open in new window

0
 

Expert Comment

by:gDueck
ID: 35086388
The tail of your query ends with (cut-and-paste) '".$pictureId."'" That's double-quote single-quote .$pictureid. double-quote single-quote double-quote. Your quotes need to be modified.

This is a debugging issue. If the query looks right but fails to execute, you might try to print the query on a console as it is being passed to MySQL to ensure the what you typed is what you wanted (wytiwyw).
0
 
LVL 5

Expert Comment

by:onemadeye
ID: 35086481
.. perhaps try to remove the ~ sign :
$sqlUpdate = "UPDATE images SET imgLarge='".$file."', imgSmall='".$save."' WHERE pictureId='".$pictureId."'";

Open in new window

0
 
LVL 1

Author Closing Comment

by:helpchrisplz
ID: 35086901
mysql_query was missing thx
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now