BrainBoxMad Posted June 12, 2013 Share Posted June 12, 2013 (edited) Hi everyone, I am quite new to the world of PHP, and really need some help, as i am getting the following error message over and over again, and cant find a solution: Parse error: syntax error, unexpected 'while' (T_WHILE), expecting ',' or ';' in E:\website\htdocs\test\test.php on line 27 Can anyone please give me some of their time and check through my code to maybe see if they can spot the problem area? Thanks. My Code is the following: <?phpinclude 'config.php';//Choose the database$selected = mysql_select_db("store",$dbhandle) or die("Could not select store"); //execute the SQL query and return results$result = mysql_query("SELECT product_id, product_name, product_type, price, description, stock, weight FROM products");echo "<table border=\"1\" cellpadding=\"3\">\n";echo "<thead>\n";echo "<tr>\n";echo "<th>ID</th>";echo "<th>Name</th>";echo "<th>Product Type</th>";echo "<th>Price</th>";echo "<th>Description</th>";echo "<th>Stock</th>";echo "<th>Weight</th>";echo "</thead>\n";echo "<tbody>\n"//retrieve that data from the database, while loop due to having more than one resultwhile($row = mysql_fetch_array($result)){ echo "ID: ".$row{"product_id"}. "<br>"; echo "Name: ".$row{"product_name"}. "<br>"; echo "Product Type: ".$row{"product_type"}. "<br>"; echo "Price: ".$row{"price"}. "<br>"; echo "Description: ".$row{"description"}. "<br>"; echo "Stock: ".$row{"stock"}. "<br>"; echo "Weight: ".$row{"weight"}. "<br>"; "<br>"; //display the results}?> Edited June 12, 2013 by BrainBoxMad Quote Link to comment Share on other sites More sharing options...
Love2c0de Posted June 12, 2013 Share Posted June 12, 2013 (edited) Good evening, You have missed off an ending semi-colon on this line: echo "<tbody>\n" Kind regards, L2c Edited June 12, 2013 by Love2c0de Quote Link to comment Share on other sites More sharing options...
BrainBoxMad Posted June 12, 2013 Author Share Posted June 12, 2013 Yes, thank you L2c, however, i am now getting the data displayed, but not correctly, as you can see below, any ideas why this may be happening? Connected to MySQLID: 1Name: ASUS 15" UltrabookProduct Type: LaptopPrice: 400Description: Test Gibrish Test Gibrish Test Gibrish Test Gibrish Test Gibrish Test Gibrish Test Gibrish Test Gibrish Test Gibrish Test Gibrish Test Gibrish Test GibrishStock: 15Weight: 8 ID Name Product Type Price Description Stock Weight Quote Link to comment Share on other sites More sharing options...
Barand Posted June 12, 2013 Share Posted June 12, 2013 Give us a clue. How do you want it to appear? Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted June 12, 2013 Share Posted June 12, 2013 your actual data output doesn't contain any <tr><td>...</td>...</tr> tags, so it is just output as is. you would probably want to add those tags if you want the data to be displayed in the table. you will also want to close the table after all the output with a </table> tag. Quote Link to comment Share on other sites More sharing options...
BrainBoxMad Posted June 13, 2013 Author Share Posted June 13, 2013 To Mac_gyver, Thanks for the above help, that got me sorted ; ) Quote Link to comment Share on other sites More sharing options...
imen Posted June 13, 2013 Share Posted June 13, 2013 If you want to display in a table, I suggest you this code <php .................................. ?> <html><head></head> <body> <?php while($row = mysql_fetch_array($result)){ ?> <tr><td><?php echo $row{"product_id"} ;?></td> <td><? php echo $row{"product_name"} ?></td></tr>............................................................................................................ ?></body></html> 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.