itgeo Posted November 20, 2013 Share Posted November 20, 2013 <!DOCTYPE html> <html lang = "en"> <head> <title> Facilities</title> <meta charset = "utf-8"/> <link type="text/css" rel="stylesheet" href="fac.css"/> <script type="text/javascript" src="fac.js"> </script> </head> <body> <?php if(isset($_POST['facNum'])) { $DBConnect = @mysql_connect("localhost", "fac90", "fac90"); if (!$DBConnect) echo "<p>The database server is not available</p>"; else echo "<p>success</p>"; $DBName ="fac90"; if (@mysql_select_db($DBName)) echo "<p></p>"; else echo "<p>The database is not available.</p>"; $facNum = $_POST['facNum']; $sqlquery = "SELECT * FROM teams WHERE facNum = '$facNum';"; $result = @mysql_query($sqlquery) or die ('<p> Error </p>'); $num_rows = mysql_num_rows($result); echo $num_rows; echo "<table width='100%' border='1'>"; echo "<tr><th>Room Num</th> <th> Name</th> <th>Department</th> <th>Materials</th> <th>Shipments</th> <th>Receivals</th> <th>Packing</th> <th>Location</th> <th>Reference</th> <th>Quantity</th> <th>Supplied by</th> <th>Phone</th> <th>Next Shipment</th> <th>Dates</th> </tr>"; $Row = mysql_fetch_assoc($result); do { echo "<tr><td>{$Row['facNum']}</td><td>{$Row['Name']}</td> <td>{$Row['department']}</td><td>{$Row['materials']}</td> <td>{$Row['shipments']}</td><td>{$Row['rec']}</td> <td>{$Row['packing']}</td><td>{$Row['loca']}</td> <td>{$Row['Reference']}</td><td>{$Row['quant']}</td> <td>{$Row['supplied']}</td><td>{$Row['phone']}</td> <td>{$Row['NextShipment]}</td><td>{$Row['dates']}</td> </tr>"; $Row = mysql_fetch_assoc($result); } while ($Row); echo "</table>"; mysql_close($DBConnect);} ?> </body> </html> Hi guys, I have a php file that is not working because I get this error "Parse error: syntax error, unexpected $end" It's saying the last line, but I put a closing bracket after "?>" and then it does not display my database at all only a blank screen. I also have a separate ..html file that has a form with the button to click for the user enters the facilityid. After the user enters the facilityID and clicks on the submit button it should display the database based on the id number, and it currently gives me the above error. Any help would be appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted November 20, 2013 Solution Share Posted November 20, 2013 Change your PHP code to <?php $DBName ="fac90"; $DBConnect = mysql_connect("localhost", "fac90", "fac90") or die("<p>The database server is not available</p>"); mysql_select_db($DBName) or die("<p>The database is not available.</p>"); if(isset($_POST['facNum'])) { $facNum = $_POST['facNum']; $sqlquery = "SELECT * FROM teams WHERE facNum = '$facNum';"; $result = @mysql_query($sqlquery) or die ('<p> Error </p>'); $num_rows = mysql_num_rows($result); echo $num_rows; echo "<table width='100%' border='1'>"; echo "<tr><th>Room Num</th> <th> Name</th> <th>Department</th> <th>Materials</th> <th>Shipments</th> <th>Receivals</th> <th>Packing</th> <th>Location</th> <th>Reference</th> <th>Quantity</th> <th>Supplied by</th> <th>Phone</th> <th>Next Shipment</th> <th>Dates</th> </tr>"; while($Row = mysql_fetch_assoc($result)) { echo "<tr><td>{$Row['facNum']}</td><td>{$Row['Name']}</td> <td>{$Row['department']}</td><td>{$Row['materials']}</td> <td>{$Row['shipments']}</td><td>{$Row['rec']}</td> <td>{$Row['packing']}</td><td>{$Row['loca']}</td> <td>{$Row['Reference']}</td><td>{$Row['quant']}</td> <td>{$Row['supplied']}</td><td>{$Row['phone']}</td> <td>{$Row['NextShipment']}</td><td>{$Row['dates']}</td> </tr>"; } echo "</table>"; mysql_close($DBConnect); } ?> Quote Link to comment Share on other sites More sharing options...
JIXO Posted November 20, 2013 Share Posted November 20, 2013 You forgot a quotation mark there Try this : <td>{$Row['NextShipment']}</td><td>{$Row['dates']}</td> Quote Link to comment Share on other sites More sharing options...
itgeo Posted November 20, 2013 Author Share Posted November 20, 2013 <!DOCTYPE html> <html lang="en"> <head><title>Facilities Information</title> <link rel="stylesheet" href="php_styles.css" type="text/css" /> <meta charset="utf-8" /> </head> <body> <h1>Facilities</h1> <form method="get" action="facilities.php"> <p>Team ID:<input type="text" name="facNum" /> <input type="submit" value="facInfo" /> </p> </form></body></html> I tried your code and it doesn't give me errors but for some reason the database still does not display (blank screen). I have this html file linking to the above php file (facilities.php). Is there something wrong with this file linking it? Quote Link to comment Share on other sites More sharing options...
JIXO Posted November 20, 2013 Share Posted November 20, 2013 Ok, for a start remove the @ signs so you can see the error ! Try change this : $sqlquery = "SELECT * FROM teams WHERE facNum = '$facNum';"; to this $sqlquery = "SELECT * FROM teams WHERE facNum = '$facNum'"; After removing @ses, post any error that might appear Quote Link to comment Share on other sites More sharing options...
itgeo Posted November 20, 2013 Author Share Posted November 20, 2013 I removed the @ and changed the line you mentioned and it still does not display an error, it is till blank. I think it has to do with me linking the above html file to the php file? Am I supposed to do something else to link them or change the html file to php? Quote Link to comment Share on other sites More sharing options...
JIXO Posted November 20, 2013 Share Posted November 20, 2013 Attach the files, and the database, I will try to debug it for you. Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted November 20, 2013 Share Posted November 20, 2013 (edited) I think it has to do with me linking the above html file to the php file? Am I supposed to do something else to link them or change the html file to php? What do you mean by that? Post the url you are using to opening the html and php file. Edited November 20, 2013 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
itgeo Posted November 20, 2013 Author Share Posted November 20, 2013 I got it to work. Thanks guys! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.