This may be a really obvious things but I've spent ages staring at it maybe just needs a new pair of eyes. <?php function license_check($url, $curl_data){ $options["CURLOPT_RETURNTRANSFER"] = false; $options["CURLOPT_HEADER"] = false; $options["CURLOPT_CONNECTTIMEOUT"] = 10; $options["CURLOPT_TIMEOUT"] = 10; $options["CURLOPT_POST"] = 1; $options["CURLOPT_POSTFIELDS"] = $curl_data; $ch = curl_init($url); curl_setopt_array($ch, $options); $content = curl_exec($ch); curl_close($ch); return $content;} $license_key = "";$post_fields = array("key" => $license_key, "registered_domain" => $_SERVER['SERVER_NAME'], "registered_ip" => $_SERVER['SERVER_ADDR'], "registered_directory" => dirname(__FILE__));$license = license_check("http://www.url-to-your-website.com/license.php", $post_fields);$xml = simplexml_load_string($license); foreach($xml->attributes() as $key => $value) { $key = $value;}if($status == "Invalid"){ die($reason);} unset($post_fields, $license, $xml, $status, $reason, $license_key, $registered_ip, $registered_domain, $registered_directory); ?> PHP: I get the error Parse error: syntax error, unexpected T_VARIABLE in /home/USERNAME/public_html/testing/license_tutorial/index.php on line 6 PHP: Any ideas? P.S. sorry abotu formatting digitalpoint seems to screw it up.
<?php function license_check($url, $curl_data) { $options["CURLOPT_RETURNTRANSFER"] = false; $options["CURLOPT_HEADER"] = false; $options["CURLOPT_CONNECTTIMEOUT"] = 10; $options["CURLOPT_TIMEOUT"] = 10; $options["CURLOPT_POST"] = 1; $options["CURLOPT_POSTFIELDS"] = $curl_data; $ch = curl_init($url); curl_setopt_array($ch, $options); $content = curl_exec($ch); curl_close($ch); return $content; } $license_key = ""; $post_fields = array("key" => $license_key, "registered_domain" => $_SERVER['SERVER_NAME'], "registered_ip" => $_SERVER['SERVER_ADDR'], "registered_directory" => dirname(__FILE__)); $license = license_check("http://www.url-to-your-website.com/license.php", $post_fields); $xml = simplexml_load_string($license); foreach ($xml->attributes() as $key => $value) { $key = $value; }if ($status == "Invalid") { die($reason); } unset($post_fields, $license, $xml, $status, $reason, $license_key, $registered_ip, $registered_domain, $registered_directory); ?> PHP: Code looks fine, no errors...
I figured out what was causing the problem just not 100% sure how to stop it happening again. Basically I copied my tutorial into my php file to check it worked and using Netbeans you can see some invalid characters were entered into the TABS/Indents. These only shown up using Netbeans
I do use Notepad++ however the only program to show up the invalid characters was Netbeans. Even notepad didnt show them.
You need to learn to writer cleaner code. Then when you debug the exact line # will be stated giving you an exact reason for failure.
That would not have made any difference as the PHP engine reports an error at different lines to what actually had the errors on. And writing cleaner code would not have stopped this problem. This was because it was copied from a ANSI web page. Which included some invalid characters.
Actually writing clean code using proper formatting and indentation allows for your code to be readable by the human eye. And the debugger will report the line number where the error is on or near. If you follow traditional programming practices a semi-colon should indicate the LAST character of code on that current line. Trust me..writing clean code makes it very easy to spot errors.