witham Posted February 23, 2008 Share Posted February 23, 2008 I would really appreciate a fresh pair of eyes looking at this code as it will not render properly it just displays the combobox at the bottom of the page. I have stared and stared had a break and stared and stared again but I cannot see the problem. I know it is something stupidly simply but "not seeing the wood for trees" springs to mind. <? //check the $ProdName variable to see if it has data if not send the user back to the entry page // this has to be done before any output $ProdName = $_GET['ProdName']; $ProdEquiv = $_GET['ProdEquiv']; $Manufacturer = $_GET['Manufacturer']; $ProdNar = $_GET['ProdNar']; $Category = $_GET['Category']; if (empty($ProdName)){ header("Location: addprod.php"); die ("opps"); } if (empty($ProdEquiv)){ header("Location: addprod.php"); die ("opps"); } $dbuser = 'test'; // your database server user name $dbhost = 'localhost'; // name of the sql server $dbpass = ''; // your database server password $dbname = 'weld'; // the name of the database to connect to // use a compare statement to check for duplicates $sqlCOMPARE = "SELECT * from prodname where '$ProdName' = proddesc;"; // the sql query to insert data into the prodname table $sqlINSERT = "INSERT into prodname values (null, '$Manufacturer', '$Category', '$ProdName', '$ProdNar', '$ProdEquiv');"; $sqlINSERT = strtoupper($sqlINSERT); //use to display the desired data $sqlSELECT $sqlSELECT = "SELECT MANNAME, prodtype, proddesc, prodnar, prodequiv FROM man, produse, prodname where manno = manid and manid = '$Manufacturer' and useid = '$Category' and prodid = useid and manno = MANID and useid = USEID order by MANNAME;"; // mysql_connect connects to the database server and returns a link to the the resource $dblink = @mysql_connect("$dbhost","$dbuser","$dbpass") or die("<p><b>Could not connect to database server: ($dbhost)</b></p>\n"); // mysql_select_db selects a database to use on the database server pointers to by $dblink // the @ sign before the command supresses any error messages @mysql_select_db ($dbname , $dblink) or die ("<p><b>Could not connect to database ($dbname)</b></p>\n"); // now execute the next query to determine if a duplicate has been entered and use // an if statement to return the user to the entry page if this is true $result = mysql_query($sqlCOMPARE, $dblink) or die("<p>Error Processing Query</p><hr /><p>".mysql_error()."</p>\n"); if ( mysql_num_rows($result) > 0 ){ header("Location: alreadyin.php"); die ("opps"); // now execute the next query to update the database table $result = mysql_query($sqlINSERT, $dblink) or die("<p>Error Processing Query</p><hr /><p>".mysql_error()."</p>\n"); // now execute the next query to display these results $result = mysql_query($sqlSELECT, $dblink) or die("<p>Error Processing Query</p><hr /><p>".mysql_error()."</p>\n"); ?> <head> <title>W.E.L.D.</title> </head> <body> <? // output the table and the first row headings echo'<table align = "center" border=0>' . "\n"; echo'<tr><td colspan = 3 align = "center"><table width="100" border="0" cellspacing="10" cellpadding="10"> <tr> <th scope="row"><img src="car.jpg" width="150" height="150"></th> <td><img src="gears.jpg" width="150" height="150"></td> <td><img src="wheel.jpg" width="150" height="150"></td> <td><img src="metalworking.jpg" width="150" height="150"></td> </tr> </table></td></tr>'; echo '<table align = "center" border="1" cellspacing="2" cellpadding="2">' . "\n"; echo "<tr bgcolor = #000000><td>MANUFACTURER</td><td>PRODUCT TYPE</td><td>PRODUCT NAME</td><td>PRODUCT DESCRIPTION</td><td>PRODUCT EQUIVALENT</td></tr>\n"; // mysql_fetch_array fetches the results from the query a row at a time each time it's called // the result is returned as an array that can be referenced either by field name or by it's index while ($row = mysql_fetch_array ($result)) // loop through the rows outputing them as html table rows // $row["fieldname"] returns the content for the field in the current row echo "<tr'><td>" . $row["MANNAME"]. "</td>"; echo "<td>" . $row["prodtype"]. "</td>"; echo "<td>" . $row["proddesc"]. "</td>"; echo "<td>" . $row["prodnar"]. "</td>"; echo "<td>" . $row["prodequiv"]. "</td></tr>";} // close html table tag echo "</table>\n"; // the mysql_free_result command removes any resources relating to the query results // this happens automatically at the end of the script but still better to free up now mysql_free_result ($result); // the mysql_close command severs the link to the database, with scripts that make multiple // queries on the same database the command only needs to be done once after all queries are completed @mysql_close ($dblink) or die( "<p><b>Error while closing connection to database server:" . "($dbhost)</b></p>"); ?> <style type="text/css"> <!-- .combobox { background-color: #000000; color: #808080; font-size: 12pt; font-family: arial; font-weight: bold; } --> </style> <form> <table align=center border="0" width="80" cellspacing="0"> <tr><td width="100%" bgcolor="#000000"> <table border="0" width="100%" cellspacing="0" cellpadding="0"> </table> <!-- put in a link returning the user to the original page --> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr><td width="2%"> <select class="combobox" name="SiteMap" onchange="if(options[selectedIndex].value){location = options[selectedIndex].value}" size="1"> <option value="">PLEASE CHOOSE AN OPTION</option> <option value="querydatabase.php">SEARCH BY MANUFACTURER & PRODUCT TYPE</option> <option value="addprod.php">ADD A PRODUCT</option> <option value="addman.php">ADD A MANUFACTURER</option> <option value="delprod.php">DELETE A PRODUCT</option> <option value="delman.php">DELETE A MANUFACTURER</option> <option value="searchweld.php">SEARCH FOR A PRODUCT BY NAME</option> <option value="amendprod.php">AMEND A PRODUCT</option> <option value="addcategory.php">ADD A CATEGORY</option> <option value="selectequiv.php">AMEND AN EQUIVALENT</option> </select> </body> </html> Link to comment https://forums.phpfreaks.com/topic/92587-page-rendering-problem/ Share on other sites More sharing options...
fooDigi Posted February 23, 2008 Share Posted February 23, 2008 the ... while ($row = mysql_fetch_array ($result)) doesn't have a beginning bracket Link to comment https://forums.phpfreaks.com/topic/92587-page-rendering-problem/#findComment-474476 Share on other sites More sharing options...
fooDigi Posted February 23, 2008 Share Posted February 23, 2008 are errors turned on for your server? Link to comment https://forums.phpfreaks.com/topic/92587-page-rendering-problem/#findComment-474481 Share on other sites More sharing options...
fooDigi Posted February 23, 2008 Share Posted February 23, 2008 i see a opening bracket on line 72, and do not see any closing until line 131, may be an issue. Link to comment https://forums.phpfreaks.com/topic/92587-page-rendering-problem/#findComment-474483 Share on other sites More sharing options...
witham Posted February 23, 2008 Author Share Posted February 23, 2008 Thanks very much for the reply can I ask what you mean by the opening bracket, still can't see it (sorry)?? I don't know if errors are turned on how would I check this please? Could you tell me why the opening and closing brackets may be an issue? Link to comment https://forums.phpfreaks.com/topic/92587-page-rendering-problem/#findComment-474499 Share on other sites More sharing options...
witham Posted February 24, 2008 Author Share Posted February 24, 2008 Thanks for the pointers for some really weird reason notepad (which I was using to edit the page source) wasn't showing the {} brackets. This is why I was a little vague and confused by the previous post!! All sorted now thanks again!! Link to comment https://forums.phpfreaks.com/topic/92587-page-rendering-problem/#findComment-475023 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.