shane201980 Posted April 12, 2010 Share Posted April 12, 2010 For starters I am a beginner when it comes to php, but I have managed to put together most of the forms and pages that I need without a whole lot of trouble. However I am currently at a loss, and my brain is smoking. The page I am attaching is intended to be password protected by a sign in form that checks a database for authentication (Which works great). However I am inserting an html sheet into the php(Simple I know) but the html includes some php to access a database and insert information into a table. By itself it works flawlessly. But when I put it in the php page for security purposes, I have developed numerous errors. Trying to work through the errors I have distroted the page extremely, and now I think it will work, but I keep getting an unexpected $end error and I cannot figure out if a curly or " is missing. Please take a look and see if you can help. it's the first time I've tried to insert an html page with php information inside a php page. I have even tried putting the if statement in reverse hoping to help... [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/198317-unexpected-end-need-help-totally-burned-out-here/ Share on other sites More sharing options...
Jax2 Posted April 12, 2010 Share Posted April 12, 2010 I you are getting an unexpected $end, it means you've forgotten to close a { that you opened somewhere... Best method to find out where you're missing one is to use this: Start your very first opening bracket on the beginning of the line, I.e.: { then, when you have another opening bracket, start it on the next indentation, such as: { { and then simply close each one as you get to the closing bracket, going back one indent, so in the end, it would look like this: { { { } { } } } that way, if your indents are off somewhere, you always know which closing bracket is missing... it's just good a scripting practice. Link to comment https://forums.phpfreaks.com/topic/198317-unexpected-end-need-help-totally-burned-out-here/#findComment-1040578 Share on other sites More sharing options...
seventheyejosh Posted April 12, 2010 Share Posted April 12, 2010 This should at least fix syntax errors... Code Highlighting editors = win. Try Komodo Edit <?php include "session.php"; include "newsession.php"; include "configck.php"; ?> <?php $user= '****'; $pass= '****'; $database="****_database"; mysql_connect('localhost',$user,$pass); @mysql_select_db($database) or die( "Unable to select database! <br> Please check your username and password."); $username=mysql_real_escape_string($_POST['user']); $password=mysql_real_escape_string($_POST['pass']); if($rec=mysql_fetch_array(mysql_query("SELECT * FROM userdata WHERE Username='$username' AND Password = '$password'"))){ if(($rec['Username']!=$username)&&($rec['Password']!=$password)){ session_unset(); echo "<font face='Verdana' size='2' color=red>Wrong Login. Use your correct Username and Password and Try Again <br><center><input type='button' value='Retry' onClick='history.go(-1)'></center>"; } else { include "newsession.php"; mysql_close(); print "<script>"; print " <html> <head> <title>Project Page</title> <meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'> <meta http-equiv='expires' content='0'> <meta http-equiv='window-target' content='_top'> </head> <body background='http://somewhere.com/Main Images/Light Blue Stripes SM.gif' Style='background-repeat: repeat-x' leftmargin='auto' topmargin='5' marginwidth='0' marginheight='0';'> <table valign='top' width='875' height='126' border='0' cellpadding='0' cellspacing='0' class='frame' id='Table_01'> <tr> <td><img src='http://somewhere.com/Main Images/Logo_TR.gif' width='485' height='75'></td></tr> <tr> <td><img src='http://somewhere.com/Main Images/Projects Header.gif' width='800' height='50'></td></tr> </table> <br> <tablevalign='top' style='margin-left:15' width='600' height='100' border='0' cellpadding='0' cellspacing='0' class='frame' id='Table_02'> <tr> <td valign='top'><font size='6'><b><u>Projects Currently Bidding</u></b><font></td></tr> <tr> <td valign='top'><font size='4'><p>Here is a listing of the current projects</font></p></td> </table> <tr> <td>"; // <- not ended ?> <?php $user1= '****'; $pass1= '****'; $db1='****_database'; mysql_connect('localhost',$user1,$pass1); @mysql_select_db($db1) or die( 'Unable to select database!'); $query1='SELECT * FROM project'; $result1=mysql_query($query1); $num1=mysql_numrows($result1); mysql_close(); $i=0; while ($i < $num) { $ID=mysql_result($result,$i,'ID'); $project=mysql_result($result,$i,'Name'); $agency=mysql_result($result,$i,'Agency'); $prevailing=mysql_result($result,$i,'Wage'); $opening=mysql_result($result,$i,'Opening'); $time1=mysql_result($result,$i,'Time1'); $amorpm1=mysql_result($result,$i,'AMorPM1'); $requested=mysql_result($result,$i,'Request'); $time2=mysql_result($result,$i,'Time2'); $amorpm2=mysql_result($result,$i,'AMorPM2'); $scope=mysql_result($result,$i,'Scope'); ?> <table bgcolor='#FFFFFF' width='750' border='0'> <tr> <td width='750'><b><font face='Arial, Helvetica, sans-serif'>Project Name: <font color='#0000EE'><? echo $project; ?></font></font></b></td></tr> <tr> <td width='750'><b><font face='Arial, Helvetica, sans-serif'>Agency/Developer: <font color='#0000EE'><? echo $agency; ?></font></font></b></td></tr> <tr> <td width='750'><font face='Arial, Helvetica, sans-serif'><b>Prevailing Wage: <font color='#0000EE'><? echo $prevailing; ?></font></font></b></td></tr> <tr> <td width='750'><font face='Arial, Helvetica, sans-serif'><b>Bid Opening: <font color='#FF0000'><? echo $opening; ?></font> @ <font color='#FF0000'><? echo $time1; ?><? echo $amorpm1; ?></font></font></b></td></tr> <tr> <td width='750'><font face='Arial, Helvetica, sans-serif'><b>Requested By: <font color='#0000EE'><? echo $requested; ?></font> @ <font color='#0000EE'><? echo $time2; ?><? echo $amorpm2; ?></font></font></b></td></tr> <tr> <td width='750'><font face='Arial, Helvetica, sans-serif'><b>Project Description: </b></font></td></tr> <tr> <td width='750'><font color='#0000EE' face='Arial, Helvetica, sans-serif'><? echo $scope; ?></font></td> </tr> <tr> <td><br><br></td></tr> <?php $i++; } // <-- no need for the quote ( " ) // <-- don't end php if you're gonna echo nextline... echo '</table>'; ?> I marked the 3 failpoints i saw right away, anyway. Lemme know. Link to comment https://forums.phpfreaks.com/topic/198317-unexpected-end-need-help-totally-burned-out-here/#findComment-1040580 Share on other sites More sharing options...
Mchl Posted April 12, 2010 Share Posted April 12, 2010 You have both missing } and missing " (at least). Use editor with syntax highlighting (like Notepad++) or even a full IDE (like NetBeans) to make debugging easier. Also there are a few just silly moment in your script (sorry). Like selecting from userdata table a user with given username and password, and then checking if selected record has this username and password. Don't you trust MySQL to give you result you ask for? Link to comment https://forums.phpfreaks.com/topic/198317-unexpected-end-need-help-totally-burned-out-here/#findComment-1040581 Share on other sites More sharing options...
shane201980 Posted April 12, 2010 Author Share Posted April 12, 2010 A little closer now, but not quite there. Jax2 - Valid point with the { they're so much easier to see when they're inline. seventheyejosh - I made the adjustments from your reply, however I did need to leave the " as it finished out my print tag. Also I tried Komodo Edit, but I'll need sometime to learn that one. Mchl - I downloaded NetBeans and found several errors which I have fixed and now I no longer have the unexpected $end error, but the sheet still does not work. Oh by the way, I took out the double check you were right it's a little silly. Ok, here is a new adjusted file. The problem now is that it does not run the second instance of querying information from the database. I get a listing of errors for undefined items for everything under the query for the database that is to be posted inside the print for the html. I hope that makes sense. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/198317-unexpected-end-need-help-totally-burned-out-here/#findComment-1040617 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.