PHP/SQL not returning any results

Problems with the Windows version of XAMPP, questions, comments, and anything related.

PHP/SQL not returning any results

Postby t4newman » 08. March 2010 12:06

When I run my php file to pull some records out of the database, now rows show up?

Any ideas?

<?php
include("utils.php");

open_db();

$adate = $_POST["arrivedate"];
$sleepers = $_POST["sleepnum"];
// echo "Arrival Date from form ".$adate."<br>";
// echo "Property that sleeps from form ".$sleepers."<br>";

//if ($adate=="") {
//}
if ($sleepers=="") {
//if ($sleepers=="") {
$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> <?= $row['city'] ?> </td>
<td> <?= $row['county'] ?> </td>
<td> <?= $row['postcode'] ?> </td>
<td> <?= $row['sleeps'] ?> </td>
<td> <?= $row['bedrooms'] ?> </td>

</tr>
<?php
$num_rows++;
}

close_db();

?>

</table>
<?=$num_rows?> results found.
t4newman
 
Posts: 2
Joined: 08. March 2010 11:52

Re: PHP/SQL not returning any results

Postby Stepke-DSL » 08. March 2010 12:29

Any error-messages?
Stepke-DSL
 
Posts: 313
Joined: 12. July 2007 16:08
Operating System: Win XP Pro SP3 + SuSe Linux

Re: PHP/SQL not returning any results

Postby t4newman » 08. March 2010 12:31

No, none.
t4newman
 
Posts: 2
Joined: 08. March 2010 11:52

Re: PHP/SQL not returning any results

Postby Stepke-DSL » 08. March 2010 12:37

Try a "normal" query like this:

Code: Select all
$db = mysql_connect("localhost", "user", "pass");
mysql_select_db("dbname");
$res = mysql_query("SELECT * FROM `table`;");
echo mysql_num_rows($res);
mysql_close($db);
Stepke-DSL
 
Posts: 313
Joined: 12. July 2007 16:08
Operating System: Win XP Pro SP3 + SuSe Linux

Re: PHP/SQL not returning any results

Postby WilliL » 08. March 2010 12:59

perhaps short_tags are switched "off"
try insted of <td> <?= $row['name']; ?> </td>
<td> <?php echo $row['name']; ?> </td>
Willi
WilliL
 
Posts: 660
Joined: 08. January 2010 10:54
Operating System: Win7Home Prem 64 SP1

Re: PHP/SQL not returning any results

Postby MC10 » 09. March 2010 06:52

If you want to turn on short tags, edit line 226:

Code: Select all
short_open_tag = Off


Turn it "On". However, it is recommended that you use <?php ?>.
MC10
 
Posts: 148
Joined: 20. February 2010 20:13


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 105 guests