Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old March 29th, 2004, 01:05 PM
treelo treelo is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 121 treelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 39 sec
Reputation Power: 2
inserting one table date into another?

php Code:
Original - php Code
  1. <?php
  2.         $conn = mysql_connect('localhost', '', '')
  3.         or die('Invalid query:' . mysql_error());
  4.         
  5.         $results = mysql_query("SELECT * FROM predictions") or die(mysql_error());
  6.       
  7.      $row = mysql_fetch_array($results);
  8.       
  9.          $winner = "INSERT into users SET points = '".$row['points']."' WHERE user_id = '".$row['user_id']."' ";
  10.  
  11.     $rs = mysql_query($winner, $conn)
  12.         or die('Invalid query:' . mysql_error());
  13.  ?>


im getting the following error with this code:

Invalid query:You have an error in your SQL syntax near 'WHERE user_id = 'treelo' ' at line 1

i have a user_id row in my users table and the name is registered, can anyone advise me why this is happening?

Reply With Quote
  #2  
Old March 29th, 2004, 02:07 PM
nazly nazly is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Colombo,SriLanka
Posts: 1,325 nazly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 18 sec
Reputation Power: 3
Send a message via Yahoo to nazly
RE: inserting one table date into another?

I think you are trying to update the records.. You can't use a WHERE clause to an INSERT statement.
To update a row use UPDATE statement..

php Code:
Original - php Code
  1.  
  2.  $conn = mysql_connect('localhost', '', '')
  3.         or die('Invalid query:' . mysql_error());
  4.        
  5.         $results = mysql_query("SELECT * FROM predictions") or die(mysql_error());
  6.      
  7.      $row = mysql_fetch_array($results);
  8.      
  9.          $winner = "UPDATE users SET points = '".$row['points']."' WHERE user_id = '".$row['user_id']."' ";
  10.  
  11.     $rs = mysql_query($winner, $conn)
  12.         or die('Invalid query:' . mysql_error());




Reply With Quote
  #3  
Old March 29th, 2004, 02:55 PM
treelo treelo is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 121 treelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 39 sec
Reputation Power: 2
RE: inserting one table date into another?

the row doesnt have any data in it, so i need to INSERT the data mate

Reply With Quote
  #4  
Old March 29th, 2004, 02:59 PM
nazly nazly is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Colombo,SriLanka
Posts: 1,325 nazly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 18 sec
Reputation Power: 3
Send a message via Yahoo to nazly
RE: inserting one table date into another?

If thats the case your syntax is wrong for INSERT..
php Code:
Original - php Code
  1.  
  2. $winner = "INSERT INTO users (points) VALUES ('".$row['points']."')";


Reply With Quote
  #5  
Old March 29th, 2004, 03:12 PM
treelo treelo is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 121 treelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 39 sec
Reputation Power: 2
RE: inserting one table date into another?

ive got it now

i did need to update it, and i also had the row names wrong

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > inserting one table date into another?


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 3 hosted by Hostway