Jump to content

Need help with strange error - Parse error: unexpected $end


johnqpublic24

Recommended Posts

Thanks for looking - I\'m trying to create a field where people can enter existing records in a database. When the PHP page first loads, they are prompted to enter the number of the record they want to change. When they enter their record, the page reloads and displays the fields of that record in text boxes. The user then has the option of changing the data and clicking the Update button.

 

I can pull up the record fine, but the code that processes the revised information gives me a strange error message:

 

Parse error: parse error, unexpected $end in c:public_htmlupdate.php on line 113

 

Where line 113 is the last line of the page. When I pull out the if (isset($_POST[\'submit\'])): block the code works fine, but with no update when submitted. Does anyone have any ideas what I\'m doing wrong?

 

 

<html>

<head>

<title> View Client </title>

</head>

<body>



<?php



 // Connect to the database server

 $dbcnx = @mysql_connect(\'localhost\');

 if (!$dbcnx) {

   die( \'<p>Unable to connect to the \' .

        \'database server at this time.</p>\' );

 }



 // Select the jokes database

 if (! @mysql_select_db(\'online\') ) {

   die( \'<p>Unable to locate the \' .

        \'database at this time.</p>\' );

 }



?>









<?php



if (isset($_POST[\'submit\'])):



 $dbcnx = mysql_connect(\'localhost\');

 mysql_select_db(\'online\');



$Status = $_POST[\'Status\'];

 $sql = \"UPDATE data SET

Status=\'$Status\' WHERE SessionID=\'$results\'\";

 if (@mysql_query($sql)) {

   echo(\'<p>data added</p>\');

 } else {

   echo(\'<p>Error adding new data: \' .

        mysql_error() . \'</p>\');

 }





?>











<?php



if (isset($_GET[\'record\'])):



$record = $_GET[\"record\"]; 





 echo(\"$record\");



 

   echo(\"<form action=\'$_SERVER[PHP_SELF]\' method=post>\");



 echo(\'<table border=1 cellpadding=5><TR bgcolor=\"#e5e5e5\"><TD>SessionID</TD><TD>Student Number</TD><TD>First Name</TD><TD>Last Name</TD><TD>Email</TD><TD>Status</TD></TR>\');













$result = @mysql_query(\"SELECT SessionID, StudentNumber, FirstName, LastName, Email, Status FROM data WHERE SessionID=\'$record\'\");



while ($row = mysql_fetch_array($result) ) {

$SessionID=$row[\'SessionID\'];

$StudentNumber=$row[\'StudentNumber\'];

$FirstName=$row[\'FirstName\'];

$LastName=$row[\'LastName\'];

$Email=$row[\'Email\'];

$Status=$row[\'Status\'];





echo(\'<TR bgcolor=\"#e5e5e5\"><TD>\' .$SessionID . \'</TD><TD><input type=text name=StudentNumber value=\' .$StudentNumber . \'></TD><TD><input type=text name=FirstName value=\' .$FirstName . \'></TD><TD><input type=text name=LastName value=\' .$LastName . \'></TD><TD><input type=text name=Email value=\' .$Email . \'></TD><TD><input type=text name=Status value=\' .$Status . \'></TD></TR>\');





}



   echo(\'<input type=submit name=submit value=submit></form>\');









?>





<?php

else: // Allow the user to enter a new author

?>



<form action=\"<?=$_SERVER[\'PHP_SELF\']?>\" method=\"get\">

<p>Look up a client (using session ID #):<br />

Email: <input type=\"text\" name=\"record\" size=\"20\" maxlength=\"255\" /><br />

<input type=\"submit\" value=\"lookup\"></p>

</form>







<?php endif; ?>



</body>

</html>

[/code]

Link to comment
Share on other sites

...maybe because of incorrect use of \'if\' statement?

[php:1:b602e2cd6d]

if(isset($_POST[\'submit\'])):

{

//do something

} else {

//do something else

}

[/php:1:b602e2cd6d]

..is wrong

..but you did use it right the second time which is maybe why that worked..

[php:1:b602e2cd6d]

if (isset($_GET[\'record\'])):

//do something

else: // Allow the user to enter a new author

endif;

[/php:1:b602e2cd6d]

..use the first if statement u mentioned like u did the second

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.