php - Parse error: syntax error, unexpected $end in myfile on line 1 -


here's code:

<?php  if(empty($_post['id'])) {     echo '<form method="post"><input type="text" name="id"><input type="submit" value="go"></form>'; } else {         $con=mysqli_connect("localhost","adminuser","adminpassword","database");     // check connection     if (mysqli_connect_errno())     {         die("dbconnect failed: " . mysqli_connect_error());     }      $remoteendpoint=$_server["remote_addr"].".".$_server["remote_port"];     $hash = md5(uniqid());     $code= mysql_real_escape_string($_post['id']);      mysqli_query($con,"insert `mobile` (`useragent`, `ip`, `hash`) values ('".$code."', '".$remoteendpoint."','".$hash."')");      echo hash; }  ?> 

with this, i'm getting

 parse error: syntax error, unexpected $end in /mylocation/index.php on line 1 

i've checked branches , can't find anything.

did miss something?

you code not report error suggest "error: syntax error, unexpected $end"

i've tested on local dev , while access denied warning mysql connection, there no php errors.

there notice: "php notice: use of undefined constant hash - assumed 'hash' "

because pointed out marc b missed $ on end of "hash" var.

this means there must more code, , actual issue in there somewhere. commonly (note, not always, often) unexpected $end error due missing curly bracket (ie opened if didn't close it). check first. if don't use editor syntax highlighting, should saves time on daft typos , late-night-tired mistakes...


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -