What's wrong with this code?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
speedy33417
Forum Contributor
Posts: 128
Joined: Sun Jul 23, 2006 1:14 pm

What's wrong with this code?

Post by speedy33417 »

I'm getting an error here. Why?

Code: Select all

$update = mysql_query("UPDATE pictures SET picture_viewed = '$result['picture_viewed']' WHERE picture_number = '$picture' AND picture_album = '$album' LIMIT 1") or die(mysql_error());
Thanks.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

I would imagine it has to do with '$result['picture_viewed']' because you are nesting single quotes... which is not allowed. For future reference, you need to use more descriptive thread titles and when you have an error... post it.
Flamie
Forum Contributor
Posts: 166
Joined: Mon Mar 01, 2004 3:19 pm

Post by Flamie »

yep, the space goat is right :)

Code: Select all

$update = mysql_query("UPDATE pictures SET picture_viewed = '".$result['picture_viewed']."' WHERE picture_number = '$picture' AND picture_album = '$album' LIMIT 1") or die(mysql_error());
Voila =)
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

curly braces are pretty kewl too

{$something['something']}

gives you an option :D
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply