| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| NamePros Regular | Select Random I'm trying to pull a random quote from my database but keep getting the following error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/t/w/i/twiztedfake/html/index.php on line 27 Line 27 is: $row = mysql_fetch_array($result); PHP Code: **Update While looking around some resource sites I found a code snipplet that seems to work for it. Here it is: PHP Code:
__________________ Four Seasons Outfitters [ 25 $NP/Month ] [ 25 $NP/Month ] [ 25 $NP/Month ] [ 25 $NP/Month] [ 25 $NP/Month] Last edited by TwiztedFake; 10-19-2006 at 12:22 PM. |
| |
| | #2 (permalink) |
| Barru. | First of all find out what the error is: PHP Code:
__________________ |
| |
| | #3 (permalink) |
| NamePros Regular | Here is the error after doing that. Even though I got the other way working I still want to figure this out. SELECT * FROM ct_quotes WHERE ID > '0' ORDER by ID RAND LIMIT 1 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'RAND LIMIT 1' at line 1
__________________ Four Seasons Outfitters [ 25 $NP/Month ] [ 25 $NP/Month ] [ 25 $NP/Month ] [ 25 $NP/Month] [ 25 $NP/Month] |
| |
| | #5 (permalink) |
| NamePros Regular | SELECT * FROM ct_quotes WHERE ID > '0' ORDER by RAND LIMIT 1 Unknown column 'RAND' in 'order clause' Thats the result.
__________________ Four Seasons Outfitters [ 25 $NP/Month ] [ 25 $NP/Month ] [ 25 $NP/Month ] [ 25 $NP/Month] [ 25 $NP/Month] |
| |
| | #7 (permalink) |
| NamePros Regular | That fixed it! I knew where the error was happening I just couldn't seem to get the correct syntax to make it work. Thanks
__________________ Four Seasons Outfitters [ 25 $NP/Month ] [ 25 $NP/Month ] [ 25 $NP/Month ] [ 25 $NP/Month] [ 25 $NP/Month] |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |