please help me to this issue. its driving me nuts for an hour :(

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /hermes/bosweb/web033/b336/ipg.asiahomecom/tile/tilesCollection.php on line 16

my line 16 code:

while($row=mysql_fetch_array($a)){

my code..
--------------------tileVerification.php----------------------

<?php
session_start();
if (!$_SESSION['user']){
    header('location: tiles.php');
    exit();
    }
?>

---------------------connectionIn.php-------------------------

$con = mysql_connect("localhost","asiahomeConnect","111")or die("cannot connect");
$db = mysql_select_db("asiahomedb")or die("cannot select Database");

---------------------connectionOut.php-------------------------

mysql_close($con);

---------------------tilesCollection.php------------------

<?php
include("tilesVerification.php");
include("connectionIn.php");
?>
<html>
    <head>
        <title>TILE COLLECTION
        </title>
    </head>
<body>
    <form id="logInForm" name="logInForm" method="post" action="">
    <table width="638" height="119" border="0" align="center" cellpadding="2" cellspacing="0">

<?php
$a=mysql_query("SELECT * FROM tiletbl");
while($row=mysql_fetch_array($a)){ 
    $tile_pic_name=$row['tile_pic'];
    $tilePicture = "img/".$tile_pic_name;
    print "<tr>";
    print "<td width='125'><img src='".$tilePicture."' width='100' height='100' border='0'></td>";
    print "<td width='229'>name:".$row['tile_name']."<br>series:".$row['tile_series']."<br>finished:".$row['tile_finish']."<br>size:".$row['tile_size']."<br>add:<br></td>";
    print "<td width='122'>download<br>edit<br>delete</td>";
    print "<tr>";
    }
?>
<a href="tilesLogout.php">log out</a>
    <p align="center">&nbsp;</p>
        </table>
    </form>
<?php
include("connectionOut.php");
?>
</body>
</html>

actually my script is work ok on localhost, but after i upload to server. they give me that error

The error means that the query was not sucessfully completed. So make sure that the $a actually is a mysql resource or not. For instance, does tiletbl exist?

how can i sure that $a is a mysql resource? yes my table is exist..

If $a is equal to false it means the query wasn't sucessful. So check for that.

Also you should use mysql_num_rows to check whether you got an empty result set. Look up that function on php.net.

yes found it! thanks websitetheme great idea. i forgot to upload my db in my hosting so why its works localy only. thank you!

Also you should use mysql_num_rows to check whether you got an empty result set. Look up that function on php.net.

thanks for idea!^^

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.