Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 8th, 2010, 06:37 AM
Authorized User
 
Join Date: Dec 2009
Posts: 85
Thanks: 16
Thanked 0 Times in 0 Posts
Default syntax error

Hi there

Very new to php - is anyone able to tell me what the correct syntax - this is what I have:

$sql = "INSERT INTO `User` SET `txtName`='$txtName', `txtUsername`='$txtUsername', `txtPassword`='$txtPassword' WHERE `fUserid`='$id'";

but I'm getting this error:

Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `fUserid`='2'' at line 1

thanks alot
 
Old September 8th, 2010, 07:10 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

seems like you are updating the data and not inserting.

Try the following:
$sql = "UPDATE `User` SET `txtName`='$txtName', `txtUsername`='$txtUsername', `txtPassword`='$txtPassword' WHERE `fUserid`='$id'";
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.
The Following User Says Thank You to om_prakash For This Useful Post:
adamhw (September 8th, 2010)
 
Old October 23rd, 2010, 04:24 AM
Registered User
 
Join Date: Oct 2010
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Thumbs up Try this

$sql = "INSERT INTO 'User' values( 'txtName'='$txtName', 'txtUsername'='$txtUsername', 'txtPassword'='$txtPassword' WHERE 'fUserid'='$id')";
The Following User Says Thank You to PatkiShailesh For This Useful Post:
adamhw (October 23rd, 2010)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: syntax error, unexpected T_ELSE in /h vipin k varghese BOOK: XSLT Programmer's Reference, 2nd Edition 4 September 29th, 2011 01:19 AM
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
Parse error: syntax error, unexpected T_STRING ginost7 Beginning PHP 1 November 9th, 2007 02:51 AM
VB Error: Syntax Error or Access Violation codehappy VB How-To 7 October 3rd, 2007 05:41 PM
VBScript error 0x800A03EA Syntax error edbkegan3 Classic ASP Databases 2 March 29th, 2004 01:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.