Wrox Programmer Forums
|
BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
This is the forum to discuss the Wrox book Beginning PHP 6, Apache, MySQL 6 Web Development by Timothy Boronczyk, Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz; ISBN: 9780470391143
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 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 May 11th, 2010, 12:32 PM
Registered User
 
Join Date: May 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch.15 transact_user.php/Change my info not working

Hi all,

I almost have the cms application fully working, the only thing that won't work is the change my information function (pg.422). When I click on change my info I get the following error:

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 user_id = 1' at line 4

I was having the same problem with Modify my Account but I found the solution on this forum already.

I had to change this:

Code:
    case 'Modify Account':
        $user_id = (isset($_POST['user_id'])) ? $_POST['user_id'] : '';
        $email = (isset($_POST['email'])) ? $_POST['email'] : '';
        $name = (isset($_POST['name'])) ? $_POST['name'] : '';
        $access_level = (isset($_POST['access_level'])) ? $_POST['access_level']
            : '';
        if (!empty($user_id) && !empty($name) && !empty($email) &&
            !empty($access_level) && !empty($user_id)) {
            $sql = 'UPDATE cms_users SET
                    email = "' . mysql_real_escape_string($email, $db) . '",
                    name = "' . mysql_real_escape_string($name, $db) . '",
                    access_level = "' . mysql_real_escape_string($access_level,
                        $db) . '",
                WHERE
                    user_id = ' . $user_id;
            mysql_query($sql, $db) or die(mysql_error($db));
        }
        redirect('cms_admin.php');
        break;
to this:

Code:
case 'Modify Account':
if (isset($_POST['name'])
and isset($_POST['email'])
and isset($_POST['access_level'])
and isset($_POST['user_id']))
{
$sql = "UPDATE cms_users " .
"SET email='" . $_POST['email'] . 
"', name='" . $_POST['name'] . 
"', access_level=" . $_POST['access_level'] . " " .
" WHERE user_id=" . $_POST['user_id'];

mysql_query($sql, $db)
or die('Could not update user account; ' . mysql_error());
}
redirect('cms_admin.php');
break;
If someone could tell how I need to alter the following code to get the Change My Information button working, I would be very grateful.
Code:
    case 'Change my info':
        session_start();
        $email = (isset($_POST['email'])) ? $_POST['email'] : '';
        $name = (isset($_POST['name'])) ? $_POST['name'] : '';
        if (!empty($name) && !empty($email) && !empty($_SESSION['user_id']))
        {
            $sql = 'UPDATE cms_users SET
                    email = "' . mysql_real_escape_string($email, $db) . '",
                    name = "' . mysql_real_escape_string($name, $db) . '",
                WHERE
                    user_id = ' . $_SESSION['user_id'];
            mysql_query($sql, $db) or die(mysql_error($db));
        }
        redirect('cms_cpanel.php');
        break;
Thanks,
Debs

Last edited by djlfreak; May 11th, 2010 at 12:37 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch.15 transact_user.php/Change my info not working djlfreak BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 2 May 12th, 2010 01:42 PM
(Ch. 1 Conflicting Info) This should be the Greatest PHP & mySQL Book - EVER mo_money BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 1 October 9th, 2009 01:37 PM
ch 13 enum_options.php not working thurmma BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 3 January 27th, 2004 04:26 AM
CH.15 NEED HELP stacy BOOK: Beginning ASP 3.0 1 January 21st, 2004 03:37 AM





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