Page 1 of 1

mysql/php returning invisible result sets!!

Posted: Sat Jan 14, 2006 5:28 am
by will83
Hello,

I hope someone knows what this problem might be;

I have designed and built a website and tested the php/mysql code using phpdev which simulates an apache/mysql/php server using the localhost on my pc.

All the queries work perfectly, however I have just uploaded my site to the actual webserver and most of the queries are returning empty result sets!

It's like they are there because for instance; a while ($row = mysql_fetch_array.... does return the correct amount of rows! One while loop I have wrapped each result in a div and u can just see empty divs for the right amount of rows!!

Another example: I have a database of keywords, a while loop prints each keyword seperated by a comma - the right amount of commas are there!


This is an example of a code that is returning empty sets:

Code: Select all

$query = "SELECT * from company_ins, company_log WHERE company_ins.ins_id = '$typeid' AND company_log.Id = company_ins.company_Id order by company_log.name";

$result = mysql_query($query, $conn);	

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

if ($row['type_featured'] != 'f') {
	
?>
<div class="linkbox">

<a href="<?php echo $row['link']; ?>" class="link" target="_blank"><strong><?php echo $row['name']; ?></strong></a>

<p><?php echo $row['description']; ?></p>

<p><a href="<?php echo $row['link']; ?>" target="_blank"><?php echo $row['link2']; ?></a></p>

</div>
<?php 
	}
}
 ?>

I just thought - do you think I need to be using an INNER JOIN select query here?

Any thoughts?

Thanks!

Will

Posted: Sat Jan 14, 2006 7:59 am
by raghavan20
You could have posted this in PHP-code....
anyway, let's deal with the problem...
you can try this...

Code: Select all

$query = "SELECT * from company_ins, company_log WHERE company_ins.ins_id = '$typeid' AND company_log.Id = company_ins.company_Id order by company_log.name"; 

$result = mysql_query($query, $conn);     
echo "Number of rows returned: ". mysql_num_rows($result);
I have seen your mysql_fetch_array statement is invalid. You do not have to provide connection object because you already have the result set object with you...

Here is the syntax from PHP manual

Code: Select all

array mysql_fetch_array ( resource result [, int result_type] )

Posted: Sat Jan 14, 2006 8:12 am
by will83
raghavan

That was it! - I removed the $conn from my mysql_fetch_array queries and da daa.

Thanks very much!!! And have a good weekend!!