Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
d3ad1ysp0rk
Forum Donator
Posts: 1661 Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA
Post
by d3ad1ysp0rk » Tue Dec 30, 2003 5:47 pm
Code: Select all
$rowsql = "SELECT * FROM `rants` WHERE 1";
$result = mysql_query($rowsql);
$rows = mysql_num_rows($result);
Can you see anything that would cause the above code to not work?
It's pretty simple, all I'm doing is getting the number of rows for my while loop later on..
Gen-ik
DevNet Resident
Posts: 1059 Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.
Post
by Gen-ik » Tue Dec 30, 2003 6:28 pm
I don't think you need the 'where 1' bit in there... normally you would use that for something like "SELECT * FROM `table` WHERE `name`='bob'".
Just try using SELECT * FROM `rants` and see if that works.
nigma
DevNet Resident
Posts: 1094 Joined: Sat Jan 25, 2003 1:49 am
Post
by nigma » Tue Dec 30, 2003 6:37 pm
Whats not working with your code? Is $rows not being assigned the number of rows returned when $rowsql query is executed?
d3ad1ysp0rk
Forum Donator
Posts: 1661 Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA
Post
by d3ad1ysp0rk » Tue Dec 30, 2003 7:36 pm
nigma, it was giving me this:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/des404/public_html/xrants/index.php on line 19
thanks for your help gen-ik, but i realized it was an error in my connection to the db.. sry for wasting ur time :p