Jump to content

php


itgeo
Go to solution Solved by Ch0cu3r,

Recommended Posts

<!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.

Link to comment
Share on other sites

  • Solution

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);
}

?>
Link to comment
Share on other sites

<!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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

 

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 by Ch0cu3r
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.