Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 15-09-06
andy_jacko's Avatar
curiouser and curiouser
 
Join Date: Sep 2003
Location: uk
Posts: 654
Thanks: 0
Thanked 0 Times in 0 Posts
andy_jacko is an unknown quantity at this point
  PHP SQL error

late night last night and I can barely see straight,

PHP Code:
  $updateSQL2 sprintf("UPDATE users SET username=%s, password=%s, WHERE id=$row_Recordset1['username']"
keep getting parse error

the error is the $row_Recordset1['username'] bit but cant remember how to corrent,

help

andy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 15-09-06
zinc's Avatar
boo!
 
Join Date: May 2006
Location: Berkshire
Posts: 677
Thanks: 0
Thanked 0 Times in 0 Posts
zinc is an unknown quantity at this point
missing a bracket?

$updateSQL2 = sprintf("UPDATE users SET username=%s, password=%s, WHERE id=$row_Recordset1['username']"),

Plus what's the comma doing on the end, can you post the rest of the line. If that is the end of the line then obviously you need a semi colon instead ;
__________________
Got web development?
www.zincstudios.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 15-09-06
andy_jacko's Avatar
curiouser and curiouser
 
Join Date: Sep 2003
Location: uk
Posts: 654
Thanks: 0
Thanked 0 Times in 0 Posts
andy_jacko is an unknown quantity at this point
sorry the rest of the code didnt get pasted

PHP Code:
  $updateSQL2 sprintf("UPDATE users SET username=%s, password=%s, WHERE id=$row_Recordset1['username']",
                       
GetSQLValueString($_POST['username'], "text"),
                       
GetSQLValueString($_POST['password'], "text")); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 15-09-06
zinc's Avatar
boo!
 
Join Date: May 2006
Location: Berkshire
Posts: 677
Thanks: 0
Thanked 0 Times in 0 Posts
zinc is an unknown quantity at this point
ignore what i said then
__________________
Got web development?
www.zincstudios.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #5 (permalink)  
Old 15-09-06
zinc's Avatar
boo!
 
Join Date: May 2006
Location: Berkshire
Posts: 677
Thanks: 0
Thanked 0 Times in 0 Posts
zinc is an unknown quantity at this point
Try getting rid of this comma...

password=%s,

-Ben
__________________
Got web development?
www.zincstudios.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 15-09-06
andy_jacko's Avatar
curiouser and curiouser
 
Join Date: Sep 2003
Location: uk
Posts: 654
Thanks: 0
Thanked 0 Times in 0 Posts
andy_jacko is an unknown quantity at this point
still getting an error,

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

regards andy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 15-09-06
Super Moderator
 
Join Date: Aug 2003
Posts: 1,984
Thanks: 1
Thanked 1 Time in 1 Post
Fraser seems to know their stuff
I think it's to do with the ' in the SQL string. You can probably get round it with backslashes or something like that but the other way would be to assign it to a variable without the ' in the name.

i.e.

PHP Code:

$id
=$row_Recordset1['username'];

$updateSQL2 sprintf("UPDATE users SET username=%s, password=%s, WHERE id=$id",
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['password'], "text")); 
__________________
Fraser

Affiliate Blog & Podcast
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #8 (permalink)  
Old 15-09-06
esnagel's Avatar
Registered User
 
Join Date: Apr 2005
Location: Buffalo, NY USA
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
esnagel is an unknown quantity at this point
Try

PHP Code:
  $updateSQL2 sprintf("UPDATE users SET username=%s, password=%s, WHERE id={$row_Recordset1['username']}",
                       
GetSQLValueString($_POST['username'], "text"),
                       
GetSQLValueString($_POST['password'], "text")); 
Curly braces around $row_Recordset1['username']. You didn't specify if it was a PHP error or MySQL error, but looking at the query, looks like a PHP error.

Eric
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 15-09-06
Super Moderator
 
Join Date: Aug 2003
Posts: 1,984
Thanks: 1
Thanked 1 Time in 1 Post
Fraser seems to know their stuff
When it's anything to do with PHP go with Eric's answer instead of mine
__________________
Fraser

Affiliate Blog & Podcast
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 15-09-06
andy_jacko's Avatar
curiouser and curiouser
 
Join Date: Sep 2003
Location: uk
Posts: 654
Thanks: 0
Thanked 0 Times in 0 Posts
andy_jacko is an unknown quantity at this point
excellent thats fixed the errors,

Im now having trouble getting the code to update 2 databases at the same time,

any ideas,

both pieces of code are similar the first updates a few more fields but i need to store usernames and passwords seperatly.


regards andy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On