Solved

update query

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Read about achieving the basic levels of HRIS security in the workplace.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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.

809 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