help with PHP / MySQL search results..

  RicScott 10:11 29 Jul 06
Locked

Hi,
I recently designed a php/MySQL web site. The database has 3 tables. properties, pages and users.
The data stored in the pages table displays fine, the Users table also works great. Now..
When I am trying to display the contents of the properties table, all goes PT.
I get errors on the page, if I silence the errors using '@' I obviously get a null return.
However, if I change the query to read from the pages table, then I get a perfect result, no problems.
The only problem is, I don't want to view the pages table where the properties are supposed to be!!..

If I put:
$query = "SELECT COUNT(*) FROM properties ORDER BY pageID ASC";

I get an error return on these lines:
$row = mysql_fetch_array ($result, MYSQL_NUM);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))

and:
mysql_free_result ($result);

I have stripped the properties table right down to only having the primary key row in the table and it stilldoes it, but if I change the query over to pages, it displays fine and behaves as it should..

Am I doing something wrong or missing something out??
If I go into MySQL prompt, type in SELECT * FROM properties;
I get the result that I need on the pages, so I know that the DB is fine.

Anybody??

  harristweed 12:53 29 Jul 06

If your counting why do you need "ORDER BY pageID ASC"

try:

$query = "SELECT COUNT(*) as Num FROM properties ";

  RicScott 13:35 29 Jul 06

Thanks for that HT..
Another I eventually figured out was to ORDER BY the primary key.. that seemed to work too...

All I need to do now is figure out a way of displaying the images from the DB...that's another story..

  harristweed 13:47 29 Jul 06

How are you storing the images?

I assume they are uplaoded to a folder on the site ( I can't believe your storing them as binary in the db!)

How i do it is when you upload the pictures, rename them to include the primary key (auto number from the database)

Then all you need to do is link using the new name.

See an example: click here

  RicScott 14:06 29 Jul 06

:o|
I was thinking of using binary...but seeing as you've siad that..

I have got a folder on the site for the property images etc already..

Just figuring it all out...having made the move from designer to developer..it's a completely different ball game..

All I used to do is design the pages..the developers handled all this side..now I know why..

  harristweed 15:22 29 Jul 06

welcome to the real world.

If you store jpg files as binary in your database, you will soon exceed your allowed space (usually limited to 10% of your disc space) Not to mention all the other problems.....

Heres how you get the last primary_key ( of whatever you have named it) from the database.

if ($lastid=mysql_insert_id($link_id));
$select = "SELECT primary_key FROM property WHERE primary_key = '$lastid'";
$results = mysql_query("$select", $link_id);
$query_data = mysql_fetch_row($results);
$key = $query_data[0];

Good luck!

  RicScott 15:09 30 Jul 06

Thanks again...

This thread is now locked and can not be replied to.

The Legend of Zelda Breath of the Wild review: Five hours with Zelda on the Nintendo Switch

1995-2015: How technology has changed the world in 20 years

How the painting-like animated sequences in A Monster Calls were created by Glassworks Barcelona

The 22 best Safari extensions | Best Safari plugins: Improve Apple's Safari web browser with these…