Jump to content

[SOLVED] Simple mysql query not working


sean14592

Recommended Posts

Hi, Im doing a simple MYSQL query and then echoing on to the page...

 

Here is the mysq connect at the top of the page, I know this works as I do echo out other things and that works..

<?php 
if (!isset($_GET['id'])) {

echo 'NO ID PROVIDED!';
exit();

}
if (isset($_GET['id'])){

$id = $_GET['id'];

// Make a MySQL Connection
mysql_connect("$db_host", "$db_username", "$db_password") or die(mysql_error());
mysql_select_db("$db_database") or die(mysql_error());

// Retrieve all the data from the "example" table
$result = mysql_query("SELECT * FROM properties where id=$id")
or die(mysql_error());  

// store the record of the "example" table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry 

?>

 

Here is the code with somehing wrong, In the database lowprice1 = 1..Yet it is not echoing the row.

<table width="100%" border="0">
              <tr>
                <td width="43%"><strong>Season</strong></td>
                <td width="16%"><strong>From</strong></td>
                <td width="16%"><strong>To</strong></td>
                <td width="25%"><strong>Price Per Week</strong></td>
              </tr>
              <?php
		  	if ($row['lowprice1'] != "") { 
              echo "<tr>
                <td>Low</td>
                <td>".$row['lowfromday1']." ".$row['lowfrommonth1']."</td>
                <td>".$row['lowtoday1']." ".$row['lowtomonth1']."</td>
                <td>£".$row['lowprice1']."</td>
              </tr>";
		  }
		  	
		  ?>
            </table>

 

 

Any help would be nice.

cheers

sean

 

Link to comment
https://forums.phpfreaks.com/topic/111389-solved-simple-mysql-query-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.