|
-
Mar 11th, 2010, 08:24 AM
#1
Thread Starter
New Member
Php Syntax help
Hi,
I'm a newbie when it comes to PHP. I currently learning the language, but stuck with the following:-
Parse error: syntax error, unexpected T_IF in /home/fhlinux192/e/eatlunch.co.uk/user/htdocs/library/register1.php on line 45
Keep getting the above message, and the lines in my php refering to this is:-
// Check Eat 1 details
$vEat1 = $_POST['Eat1'];
if (!empty(trim($vEat1))) { <-- this is line 45 in my script
/* Not empty */
$sSQL = "INSERT INTO webelorderdetails (SessionID, MSelect_Code, MSelect_Desc, MSelect_Qty) VALUES ('$sid', 'WM0001-000000', 'Eat 1', '$BuffetDate')";
$result = mysql_query($sSQL, $conn);
}
I don’t know what the correct syntax should be, any helpful pointers.
Regards
-
Mar 11th, 2010, 09:13 AM
#2
Re: Php Syntax help
there is nothing wrong with your syntax. however, there is something wrong with your use of empty(). empty() is a function that checks if a variable is either true or false, and will not check whether a function call is true or false. this is in the documentation for empty().
if you change your code slightly, you will be fine:
PHP Code:
// Check Eat 1 details $vEat1 = trim($_POST['Eat1']); if (!empty($vEat1)) {
also, in the future you might want to use [php] and [/php] tags to display your code. it's much easier to read.
-
Mar 11th, 2010, 09:41 AM
#3
Thread Starter
New Member
Re: Php Syntax help
Hi kows,
Thanks you for the prompt reply, I will updae my script and post any furthr developments.
Thanks
-
Mar 14th, 2010, 05:03 AM
#4
Re: Php Syntax help
And ensure that you read what the manual says before you copy and paste code from it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|