Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

update query

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

Question has a verified solution.

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

Suggested Solutions

Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
The viewer will learn how to count occurrences of each item in an array.

792 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