SunQuest
 
           MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 3rd, 2007, 02:36 AM
cty cty is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 18 cty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 9 m 16 sec
Reputation Power: 0
SQl syntax

can anyone help me to edit it to correct form?


$query="insert into book(buyer) values('".$x."')where id=".$book;

Reply With Quote
  #2  
Old March 3rd, 2007, 02:57 AM
Humanetainit's Avatar
Humanetainit Humanetainit is offline
Beyond help
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: The Netherlands
Posts: 223 Humanetainit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 32 m 30 sec
Reputation Power: 2
Quote:
Originally Posted by cty
$query="insert into book(buyer) values('".$x."')where id=".$book;
Hardly a php question, but what the heck. Do you want this:
Code:
$query="INSERT INTO `book` SET buyer='" . $x . "' WHERE id=" . $book;
This is my preferred way of writing SQL queries, but your way is not wrong. A great way of learning SQL is using phpMyAdmin. It echoes out all it's queries, so you can see what it does.
__________________
One World... Humanetainit | Program secure

Reply With Quote
  #3  
Old March 3rd, 2007, 07:37 PM
Viper_SB's Avatar
Viper_SB Viper_SB is offline
Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Canada
Posts: 330 Viper_SB User rank is Private First Class (20 - 50 Reputation Level)Viper_SB User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 4 h 51 m 6 sec
Reputation Power: 5
A WHERE cause has to be used with an UPDATE query instead of INSERT INTO.
Code:
UPDATE `book` SET buyer='xxx' WHERE id=123


Moved thread to Mysql forum
Comments on this post
Humanetainit agrees:

Reply With Quote
  #4  
Old March 4th, 2007, 03:23 AM
Humanetainit's Avatar
Humanetainit Humanetainit is offline
Beyond help
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: The Netherlands
Posts: 223 Humanetainit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 32 m 30 sec
Reputation Power: 2
Silly me...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > SQl syntax


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway