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 April 15th, 2010, 12:35 PM
Registered User
 
Join Date: Apr 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Commit

Hi would anybody be able to help me, i try to Edit a record in my database and the following error occurs..

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 '@webcase.com username = bbradshaw password = password WHERE ' at line 4

That is my commit script below, any help would be much appreciated!

<?php
require 'db.inc.php';

$db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or
die ('Unable to connect. Check your connection parameters.');
mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db));
?>
<html>
<head>
<title>Commit</title>
</head>
<body>
<?php
switch ($_GET['action']) {
case 'add':
switch ($_GET['type']) {
case 'projectmember':
$query = 'INSERT INTO
projectmember
(firstname, surname, email, username, password)
VALUES
("' . $_POST['firstname'] . '",
"' . $_POST['surname'] . '",
"' . $_POST['email'] . '",
"' . $_POST['username'] . '",
"' . $_POST['password'] . '")';
break;
}
break;
case 'edit':
switch ($_GET['type']) {
case 'projectmember':
$query = 'UPDATE projectmember SET
firstname = "' . $_POST['firstname'] . '",
surname = ' . $_POST['surname'] . ',
email = ' . $_POST['email'] . '
username = ' . $_POST['username'] . '
password = ' . $_POST['password'] . '
WHERE
memberID = ' . $_POST[''];
break;
}
break;
}

if (isset($query)) {
$result = mysql_query($query, $db) or die(mysql_error($db));
}
?>
<p>Done!</p>
</body>
</html>
 
Old April 15th, 2010, 12:45 PM
Registered User
 
Join Date: Apr 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the table in question is below, and the data inside it.

$query = 'CREATE TABLE IF NOT EXISTS projectmember (
memberID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
firstname VARCHAR(40) NOT NULL DEFAULT "",
surname VARCHAR(40) NOT NULL DEFAULT "",
email VARCHAR(40) NOT NULL DEFAULT "",
username VARCHAR(40) NOT NULL DEFAULT "",
password VARCHAR(40) NOT NULL DEFAULT "",

PRIMARY KEY (memberID)
)
ENGINE=MyISAM';
mysql_query($query, $db) or die (mysql_error($db));

--------------------------------------------------------------------------

$query = 'INSERT INTO projectmember(memberID, firstname, surname, email, username, password)
VALUES (1,"Bernard", "Bradshaw", "[email protected]", "bbradshaw", "password")';





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chap 6 commit.php errors? drgnhiker BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 1 February 12th, 2010 11:45 PM
chapter 7 commit.php ratxamala BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 November 2nd, 2005 09:24 AM
Commit & Rollback in ASP software_developer_kk Classic ASP Basics 1 June 27th, 2005 12:13 AM
Chapter 6 commit.php czambran BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 4 October 3rd, 2004 10:20 PM
ch 7 page 208 commit.php pipdickenz BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 September 8th, 2004 12:08 PM





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