Jump to content

[SOLVED] Issue with a simple select statement


owen.aaron

Recommended Posts

Im not sure if this is a php or mysql issue honestly. Im trying to set up a basic call from a MySQL DB. I have added the lines,

 

if (!$link) {

die('Could not connect: ' . mysql_error());

}

echo 'Connected successfully';

 

In the connect string so I can see the bd is connected but no data is displayed. The output of this code can be found here http://kerseyre.com/waterfront.php, if anyone can help me find the error of my ways it would be greatly appreciated =)

 

<?php
include('dbconnect.php');



	$query=mysql_query("SELECT * FROM Property ORDER by price");
	while($fetch=@mysql_fetch_array($query)) {
	$waterfront.="
	<td width='200' bgcolor='8BA446'>$fetch[address]</td><td width='75' bgcolor='8BA446'>$fetch[acreage]</td><td width='100' bgcolor='8BA446'><p>$</p>$fetch[price]</td><td width='125' bgcolor='8BA446'>Pictures</td>";
	}
print "	
</html>		
<head></head>

<body bgcolor='FEF1B5'>

<center>
<table border='1' cellpadding='0' cellspacing='1'  bordercolor='4F4F2F'>
<tr>
	<td colspan='4' bgcolor='458B00'><center><div style='font-size:20;font-weight: bold;' >County</div></center></td>
</tr>
<tr>
	<td width='200' bgcolor='8BA446'>Address</td>
	<td width='75' bgcolor='8BA446'>Acreage</td>
	<td width='100' bgcolor='8BA446'>Price</td>
	<td width='125' bgcolor='8BA446'>Pictures</td>
</tr>
	<tr>
$waterfront

</tr>
</table>
</center>

</body>
</html>";

?>

Link to comment
Share on other sites

Thought i would add the DB info,

 

version 5.0.24a

table setup...

 

Field Type Null Default

address  text No     

type  text No     

lot_number  smallint(6) No     

acreage  smallint(6) No     

picture1  text No     

id  tinyint(4) No     

price  mediumint(10) No  0   

 

 

Indexes: Keyname Type Cardinality Field

PRIMARY  PRIMARY 2  id 

 

Link to comment
Share on other sites

When creating an app, always check for errors after a query.

 

$query=mysql_query("SELECT * FROM Property ORDER by price");
if (mysql_errno()) echo "Error: " . mysql_error();

 

See if that produces any output.

 

Also, is there any data in your table?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.