|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
supplied argument is not a valid MySQL result resource
ERROR: supplied argument is not a valid MySQL result resource
Refers to this code: $date=mysql_result ($result,$i,"date"); The MySQL version on my server is 4.0.22-standard-log |
|
#2
|
|||
|
|||
|
The mysql_query() that's supposed to populate $result is failing for some reason, probably either a connection issue or a syntax error. You can add an 'or die(mysql_error())' to the end of you query call to get a more informative error message. Also double-check your query string, especially if you're using variables in it.
|
|
#3
|
|||
|
|||
|
Quote:
Here is the full error message: Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/jwgmgcom/public_html/index_data.php on line 29 And here is the complete code, except for the html part. <?php include("dbinfo.inc.php"); $query = "SELECT * FROM programs WHERE field='date' ORDER BY date DESC('$date','$progname','$progurl','$joinbonus','$reflevels','$earnratio','$surftimer','$allowurls')or die(mysql_error())"; $result=mysql_query($query); $i=0; while($i < $num) $num=mysql_numrows($result); { $date=mysql_result($result,$i,"date"); $progname=mysql_result($result,$i,"progname"); $progurl=mysql_result($result,$i,"progurl"); $joinbonus=mysql_result($result,$i,"joinbonus"); $reflevels=mysql_result($result,$i,"reflevels"); $earnratio=mysql_result($result,$i,"earnratio"); $surftimer=mysql_result($result,$i,"surftimer"); $allowurls=mysql_result($result,$i,"allowurls"); ?> |
|
#4
|
|||
|
|||
|
Quote:
You were right. My query syntax was in error. The script works just fine now. However, I wish to select only records that have data in the date field. How do I do that? The current correct query syntax is: $query="SELECT * FROM programs ORDER BY date DESC"; |
|
#5
|
|||
|
|||
|
Actually, the or die() call needs to go after the '$result=mysql_query()' line, not the '$query=' line.
Depending on what sort of default you've got your date field set to, this may work: Code:
SELECT * FROM programs WHERE date != '' ORDER BY date DESC |
|
#6
|
|||
|
|||
|
Quote:
Already moved the or die(). And here's the new $query and $result: $query="SELECT * FROM programs WHERE date LIKE '1%' ORDER BY date DESC"; $result=mysql_query($query)or die(mysql_error()); Thanks for your help! |
|
#7
|
|||
|
|||
|
Will your date data always start with a 1?
|
|
#8
|
|||
|
|||
|
Quote:
Nope. Date format is dd/mm. Will your example work with that? |
|
#9
|
|||
|
|||
|
Depends on what that field's supposed to default to. If it defaults to empty, it should. If that doesn't work, you can also try WHERE date IS NOT NULL instead of WHERE date != ''.
|
|
#10
|
|||
|
|||
|
Quote:
It works like it is, but I'll save this info in case there is a problem down the line. On to the next issue, numerical items. Some of the programs start with a number like 01likeit. I want all those programs listed on one page. Will this do the trick? $query="SELECT * FROM programs WHERE progname REGEXP '^[^A-Za-z]' ORDER BY progname ASC"; |
|
#11
|
|||
|
|||
|
I'd probably try something like
WHERE progname REGEXP '^[0-9]' instead. That'll guarantee a numeral. |
|
#12
|
|||
|
|||
|
Quote:
If I use WHERE progname LIKE 'C%'will that return all entries beginning with the letter c, or just those that begin with an uppercase c? |
|
#13
|
|||
|
|||
|
Using this query
$query="SELECT * FROM programs WHERE progname REGEXP '^[0-9]' ORDER BY progname ASC"; how can I exclude data from the query? What I want to exclude is data with the entries AE and BE in the CODE field. In other words, all records 0-9 that do not have AE or BE in the code field. |
|
#14
|
||||
|
||||
|
My MySQL skills are a bit rusty, but I think this works:
Code:
SELECT * FROM programs WHERE progname REGEXP '^[0-9]' AND code NOT LIKE '%AE%' AND code NOT LIKE '%BE%' ORDER BY progname ASC"; Keeping up with Regular Expressions... you could try: Code:
SELECT * FROM programs WHERE progname REGEXP '^[0-9]' AND code NOT REGEXP '(AE|ae|BE|be)' ORDER BY progname ASC"; Then again, my regular exression skills are even rustier than my mysql skills. =) Let me know if either of these work |
|
#15
|
|||
|
|||
|
Quote:
|