results from database
Posted by: t4newman (---.nhs.uk)
Date: February 18, 2010 03:21PM

My php script runs and no errors are generated - it's just that the query to the database does not display any results? The code works on public website (obviously with different host, user, password etc)?


<?php

$con = mysql_connect("localhost","root",""winking smiley;
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("ccn", $con);


$sleepers = $_POST["sleepnum"];


if ($sleepers==""winking smiley {

$sql = "SELECT * FROM properties";

} else {

$sql = "SELECT * FROM properties WHERE sleeps = '".$sleepers."'";
echo "Searching for: ".$sleepers."<br>";
}

//echo $sql."<br>";


?>
<table width="800" border="1">
<?php
$num_rows = 0;
$result = mysql_query($sql);

while($row = mysql_fetch_array($result))
{

?>
<tr>
<td> <?= $row['name']; ?> </td>
<td> <?= $row['area']; ?> </td>
<td> <?= $row['city'] ?> </td>
<td> <?= $row['county'] ?> </td>
<td> <?= $row['postcode'] ?> </td>
<td> <?= $row['sleeps'] ?> </td>
<td> <?= $row['bedrooms'] ?> </td>
</tr>
<?php
$num_rows++;
}

mysql_close($con);
?>

</table>
<?=$num_rows?> results found.

Options: ReplyQuote
Re: results from database
Posted by: t4newman (---.nhs.uk)
Date: February 18, 2010 03:21PM

Sorry, can't add to MSN as at work and it's blocked.

Options: ReplyQuote
Re: results from database
Posted by: stevenmartin99 (---.b-ras2.blp.dublin.eircom.net)
Date: February 18, 2010 05:57PM

you have <? and <?php make sure short tags are enabled


left click wamp > php > phpsettings> short_open_tags

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: results from database
Posted by: t4newman (---.nhs.uk)
Date: February 18, 2010 06:10PM

Thank you, that worked a treat!

You guys are great on this forum - such quick responses - thank you very much!

Regards
Terry.

Options: ReplyQuote


Sorry, only registered users may post in this forum.