473,396 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PHP Parse error

Can someone tell me whats up with this code please?

$update_query = "UPDATE users SET creditremaining = creditremaining - " .
$_REQUEST['MsgCount'] . "WHERE mobilenumber = " . $_REQUEST['From'] . "";

where creditremaining is a MySQL table field, and $_REQUEST['XXX'] is a
HTTP GET variable.

Thanks,

Ben
--
BWGames
to email change de.news to de-news
Jul 17 '05 #1
7 2178
*** BWGames wrote/escribió (Wed, 14 Apr 2004 10:08:48 +0100):
$update_query = "UPDATE users SET creditremaining = creditremaining - " .
$_REQUEST['MsgCount'] . "WHERE mobilenumber = " . $_REQUEST['From'] . "";


You should have copied the PHP error you get: I get none. In any case,
please note there isn't a space before WHERE so the database query won't
work.

Also, you should use mysql_escape_string() because you never know what
$_REQUEST will contain.

--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #2
BWGames scribbled something along the lines of:
Can someone tell me whats up with this code please?

$update_query = "UPDATE users SET creditremaining = creditremaining - " .
$_REQUEST['MsgCount'] . "WHERE mobilenumber = " . $_REQUEST['From'] . "";

where creditremaining is a MySQL table field, and $_REQUEST['XXX'] is a
HTTP GET variable.


'cept for the missing space before "WHERE" there is no problem. Maybe
you missed the final semicolon in the line before that?
In most cases parsing errors are caused by unclosed brackets or missing
semi-colons one row before the one deemed faulty in the error message.

--
Alan Plum, WAD/WD, Mushroom Cloud Productions
http://www.mushroom-cloud.com/
Jul 17 '05 #3
On Wed, 14 Apr 2004 11:44:18 +0200, in comp.lang.php, Ashmodai wrote:
BWGames scribbled something along the lines of:
Can someone tell me whats up with this code please?

$update_query = "UPDATE users SET creditremaining = creditremaining - " .
$_REQUEST['MsgCount'] . "WHERE mobilenumber = " . $_REQUEST['From'] . "";

where creditremaining is a MySQL table field, and $_REQUEST['XXX'] is a
HTTP GET variable.


'cept for the missing space before "WHERE" there is no problem. Maybe
you missed the final semicolon in the line before that?
In most cases parsing errors are caused by unclosed brackets or missing
semi-colons one row before the one deemed faulty in the error message.


That's funny, as I get:

Parse error: parse error in /www/page.php on line 16, where line 16 is:

$update_query = "UPDATE users SET creditremaining = creditremaining - " .
$_REQUEST['MsgCount'] . " WHERE mobilenumber = " . $_REQUEST['From'] . "";

The line after that is
If ($update_result = mysql_query($update_query)) {

I can't see aproblem with either of the lines either..

Anyone?

Thanks for the help so far :)

Ben
--
BWGames
to email change de.news to de-news
Jul 17 '05 #4
On Wed, 14 Apr 2004 11:02:57 +0100, in comp.lang.php, BWGames wrote:

I can't see aproblem with either of the lines either..

Anyone?

Thanks for the help so far :)

Ben


(bad form to reply to my own post, but sorry!)

Ooops sorry!

The problem was a missing ) in the preceding IF statement.

Sorry all!

Ben
--
BWGames
to email change de.news to de-news
Jul 17 '05 #5

"BWGames" <de*****@bwgames.net> wrote in message
news:dz***************@tehlan.co.uk...
Can someone tell me whats up with this code please?

$update_query = "UPDATE users SET creditremaining = creditremaining - " .
$_REQUEST['MsgCount'] . "WHERE mobilenumber = " . $_REQUEST['From'] . "";

where creditremaining is a MySQL table field, and $_REQUEST['XXX'] is a
HTTP GET variable.


In addition to the other comments, I'm sure your 'mobilenumber' field
oughtn't be numeric (you won't be carrying out any math on it, and you'll
lose leading zeroes) - it should be encased in single quotes if it's a
string.

FWIW, I cut&pasted that line into my test file and syntactically, it works
fine.

Garp
Jul 17 '05 #6
BWGames <de*****@bwgames.net> wrote in news:cu**************@tehlan.co.uk:
Ooops sorry!

The problem was a missing ) in the preceding IF statement.

Sorry all!


It's *very* important to realize that a parser can't detect the exact point
at which an error occurs. All it can do is detect the point where its
input stops making sense according to the language's grammar; this is
almost always going to occur quite a ways *after* the actual mistake.

For example, if you leave off the closing parenthesis on an if condition,
the parser will try to read the next statement as if it was still part of
the if condition. It won't be able to detect an error until it runs across
something that can't legally occur inside an if condition, and that may be
well into the next statement, or even the statement after it.
Jul 17 '05 #7
Eric Bohlman scribbled something along the lines of:
BWGames <de*****@bwgames.net> wrote in news:cu**************@tehlan.co.uk:

Ooops sorry!

The problem was a missing ) in the preceding IF statement.

Sorry all!

It's *very* important to realize that a parser can't detect the exact point
at which an error occurs. All it can do is detect the point where its
input stops making sense according to the language's grammar; this is
almost always going to occur quite a ways *after* the actual mistake.

For example, if you leave off the closing parenthesis on an if condition,
the parser will try to read the next statement as if it was still part of
the if condition. It won't be able to detect an error until it runs across
something that can't legally occur inside an if condition, and that may be
well into the next statement, or even the statement after it.


That was my point. Usually a missing (closing) bracket or semicolon does
exactly that, eg:

if (isset($a) {
// some code
}

(missing bracket after "isset")

or

$bar = 10 * 5 + 3
$foo = $bar;

(missing semicolon in the first row)

In the second example the error will occur in the row AFTER the one
missing the bracket.

--
Alan Plum, WAD/WD, Mushroom Cloud Productions
http://www.mushroom-cloud.com/
Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steven | last post by:
I got a "Parse error: parse error in ..." in this line: if(empty($_POST){ ..... But if I fist assign $ssn=$_POST; and then if(empty($ssn){ ... it is working. Any advice? Thanks in advance.
1
by: H.L Bai | last post by:
hi, everybody i meet a parse error when i used the xml4c. any proposal is helpful. The error is following .../XMLRegionHandler.h:59 parse error before '*' .../XMLRegionHandler.h:60 parse...
2
by: Vittal | last post by:
Hello All, I am trying to compile my application on Red Hat Linux 8 against gcc 3.2.2. Very first file in application is failing to compile. I tried compiling my application on Linux 7.2...
21
by: BWIGLEY | last post by:
Basically I've just started making a game. So far it makes an array 25 by 20 and tries to make five rooms within it. In scr_make_room() there's parse errors: 20 C:\c\Rooms\Untitled1.c parse error...
6
by: trevor | last post by:
Incorrect values when using float.Parse(string) I have discovered a problem with float.Parse(string) not getting values exactly correct in some circumstances(CSV file source) but in very similar...
5
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
1
by: Phaelle | last post by:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' What does that error mean? I can´t find the mistake!! In another script, I have got another kind of mistake : parse...
2
by: Lawrence Krubner | last post by:
Imagine a template system that works by getting a file, as a string, and then putting it through eval(), something like this: $formAsString = $controller->command("readFileAndReturnString",...
5
by: goldtech | last post by:
SAX XML Parse Python error message Hi, My first attempt at SAX, but have an error message I need help with. I cite the error message, code, and xml below. Be grateful if anyone can tell me...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.