May 22, 2009 6:21 am
Lan MindHello,
I'm getting :
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/l/a/
n/lanmind/html/lanmindphp.php on line 60
Line 60:
mysql_query("UPDATE answers SET answer= '$userinput' WHERE id=
'$_SESSION['selectedid']'");
I know it has to do with the session array and I'm wondering if I
remove the single quotes around 'selectedid' will it function ok?
May 22, 2009 7:55 am
J.ke?ler-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Lan Mind wrote:
> Hello,
>
> I'm getting :
>
> Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
> expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/l/a/
> n/lanmind/html/lanmindphp.php on line 60
>
> Line 60:
>
> mysql_query("UPDATE answers SET answer= '$userinput' WHERE id=
> '$_SESSION['selectedid']'");
>
> I know it has to do with the session array and I'm wondering if I
> remove the single quotes around 'selectedid' will it function ok?
Hello,>
> I'm getting :
>
> Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
> expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/l/a/
> n/lanmind/html/lanmindphp.php on line 60
>
> Line 60:
>
> mysql_query("UPDATE answers SET answer= '$userinput' WHERE id=
> '$_SESSION['selectedid']'");
>
> I know it has to do with the session array and I'm wondering if I
> remove the single quotes around 'selectedid' will it function ok?
It is okay to write this line the way you do it.
But as you can see it can lead to problems and errors.
There is a much safer way. Alhough some more to code but you avoid such errors.
mysql_query("UPDATE answers SET answer= '".$userinput."' WHERE id=
'".$_SESSION['selectedid']."'");
As you can see I end the Sting with " and add the variable with the . operator
and start the string again.
Also read somethin about sql injections. Your code can easily be exploited and
the mysql database deleted.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkoWWnMACgkQE++2Zdc7EtcVXwCdHrz89ZDAXGPq+a8tQAKhfp5R
zZAAnRto6jXxSC7wqNpeqh476GXLNtzd
=tasy
-----END PGP SIGNATURE-----
May 22, 2009 9:04 am
?lvaro G. VicarioLan Mind escribi?:
> Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
> expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/l/a/
> n/lanmind/html/lanmindphp.php on line 60
>
> Line 60:
>
> mysql_query("UPDATE answers SET answer= '$userinput' WHERE id=
> '$_SESSION['selectedid']'");
>
> I know it has to do with the session array and I'm wondering if I
> remove the single quotes around 'selectedid' will it function ok?
> expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/l/a/
> n/lanmind/html/lanmindphp.php on line 60
>
> Line 60:
>
> mysql_query("UPDATE answers SET answer= '$userinput' WHERE id=
> '$_SESSION['selectedid']'");
>
> I know it has to do with the session array and I'm wondering if I
> remove the single quotes around 'selectedid' will it function ok?
Wrap your array in brackets:
mysql_query("UPDATE answers SET answer= '$userinput' WHERE
id='{$_SESSION['selectedid']}'");
http://es2.php.net/manual/en/language.types.string.php#language.types.string.parsing
-- http://alvaro.es - ?lvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programaci?n web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
-- Mi sitio sobre programaci?n web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Previous Thread: PHP Question: passing objects by using an array
Next Thread: Slice a mulitdimensional array?
Related Forum Topics
- Parsing Error
- [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from ...
- Tokan error & 401 fatal error while running google analytics API codeon dedicated server
- Custom error-handling creates "500 internal server error"
- Re: Custom error-handling creates "500 internal server error"
- XML parsing problem
- Need help with JSON parsing with PHP
- Issue with a xml parsing
- DOM parsing problems
- SimpleXML parsing need help