Re: Sessions and MySQL?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 16 Oct 2003 13:33:28 +0100
Tristan.Pretty@risk.sungard.com wrote:

> Not sure if this is a MySQL Q. or a PHP one, but here goes...
> 
> I'm just learning sessions...
> And I'm trying to add a session variable to a MySQL database.
> I've done this page that takes the results from a previous form...
> But I get this error:
> Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or 
> `T_NUM_STRING' 
>         On line 83
> Which is the line that relates to the line:
>                 \"$_SESSION['salutation'];\", 
> 
> I've tried removing the ';' but it change nothing...?
> Can anyone see my error?
> 

Tristan,

yes, You are alternating between curly braces {} and parenethes ()
(spelling??). Also you forgot to the closing double quotes when
completeing the mysql_query statement.

You could also put the insert statement into a vairable and echo that to
the screen. That way if you can't see the error, paste the query text
into the mysql command line client.

See my alterations to you code below..

Regards


George Patterson

> =================
> <?
> session_start();
> header("Cache-control: private");
> 
>    $_SESSION['salutation'] = $_POST['salutation'];
> 
> //MySQL connection stuff
>         mysql_query("INSERT INTO $table (
>                 salutation,
>                 name,
>                 city
>                 ) VALUES (
>                 \"$_SESSION['salutation'];\", 
>                 \"$_SESSION['name'];\", 
>                 \"$_SESSION['city'];\"
>         )";
> 
> ?>
> //Rest of page... thanks etc...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux