Solved

update query

Posted on 2011-03-09
4
365 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

911 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

21 Experts available now in Live!

Get 1:1 Help Now