When I do this query directly from PHP my admin I got 5 results.
SELECT img FROM `table`.`goog` WHERE `url` LIKE '%google.com%' and `pictureID` != 'picture_50d22657a423b6.62354164';
however, when my code
$sql2 = "SELECT img FROM `table`.`goog` WHERE `url` LIKE '%$url%' and `pictureID` != '$pictureID';";
// echo $sql2;
$result2=mysql_query($sql2);
$rows2 = mysql_fetch_array($result2);
mysql_close($con);
print_r(count($rows2));
echo "<br/>";
echo $sql2;
it prints out
2
SELECT img FROM `ashkan`.`goog` WHERE `url` LIKE '%66.228.42.45%' and `pictureID` != 'picture_50d22657a423b6.62354164';
I would also like to note that the query I run inside of php my admin is copied from what my code returns..
So, why does one returns only 2 items, and the other returns 5?
EDIT
I added the following to the bottom
var_dump($rows2);
echo "<br/>";
echo mysql_num_rows($result2);
and got this
array(2) { [0]=> string(1) "b" ["img"]=> string(1) "b" }
5
I have something that manually selects a row
Essentially I want to be able to do
echo $rows2[somenum]; //that some number is at random and only one at a time
however, as is, I can only access item 0 and not all five.
mysql_*functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.