Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-22-2012, 11:43 AM   PM User | #1
globetrotter
New to the CF scene

 
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
globetrotter is an unknown quantity at this point
Question Parse error : syntax error in PHP

Hello,

I'm bit new to PHP. Could anyone please tell me what's wrong in the below code snippet?

1. <?php
2. $_page = null;
3. include(MODS_DIRECTORY."/client.php");
4. $auth_url = "http://localhost/server.php";
5. $data = file_get_contents();
6. $result = json_decode($result);
7. if($result['valid'] != true){
8. die("Invalid Key. Script Stopped!")
9. }
10. ?>


I'm getting Syntax Parse error: Unexpected '}' at line no.9

Thanks!
globetrotter is offline   Reply With Quote
Old 12-22-2012, 02:16 PM   PM User | #2
Custard7A
Regular Coder

 
Custard7A's Avatar
 
Join Date: Jul 2010
Location: Australia
Posts: 269
Thanks: 32
Thanked 32 Times in 32 Posts
Custard7A is an unknown quantity at this point
The die statement on line 8 has no semi-colon after it.
Custard7A is offline   Reply With Quote
Old 12-22-2012, 03:32 PM   PM User | #3
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Interestingly enough, and I don't suggest you do this for both readability and code adding reasons, if you omit the braces and use single instruction evaluation on the if block, your code would have worked fine. In PHP, you don't require the semi-colon on the very last instruction in a script. I personally feel this is a bug in the core that was passed off as a feature though, so you really shouldn't rely on that. Just thought I'd make a mention of it.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Tags
php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:08 PM.


Advertisement
Log in to turn off these ads.