I've been given a task where I have to create a PHP based shopping cart but have run into a rather large problem that I cannot for the life of me be able to figure out.
For some strange reason my .PHP pages refuse to actually run the PHP script that I have attached (this is including off a friends website where I get the Could not connect: Lost connection to MySQL server at 'reading initial communication packet', system error: 110 error). The thing to top it all off however is supposedly the PHP -actually- works and have had it tested by someone else .. but I have no way of seeing this as it does not seem to load up.
If anyone could tell me where I'm going wrong, I would greatly appreciate it.
<?php
$con = mysql_connect("hostname","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("co525", $con);
$result = mysql_query("SELECT * FROM beer WHERE country_id = 3");
echo "<table border='1'>
<tr>
<th>ABV%</th>
<th>Bottle Size (mL)</th>
<th>Case Size</th>
<th>Price</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['abv'] . "</td>";
echo "<td>" . $row['bottleSize'] . "</td>";
echo "<td>" . $row['caseSize'] . "</td>";
echo "<td>" . $row['price'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
(I cut out the HTML and changed the hostname, username and password)
I will attach a screenshot of the browser also.
Thank you for your time,
Noir.
Attached File(s)
-
terribad.bmp (1.05MB)
Number of downloads: 20
This post has been edited by Noirdeathe: 23 February 2012 - 09:42 PM

New Topic/Question
Reply



MultiQuote




|