n1concepts Posted November 26, 2010 Share Posted November 26, 2010 I need someone to look over snippet PHP code I have where I'm trying to query a MySQL db and echo out the results if an exact match - based on the "WHERE" clause is found during the query. See code below: $rcheck = "SELECT docno,fdate,ftime,vegregno,direction,grossmass FROM information where docno = $docnoNew AND fdate = $fdateNew AND ftime = $ftimeNew AND vegregno = $vegregnoNew AND direction = $directionNew AND grossmass = $grossmassNew;"; $duplicate = mysql_query(rcheck); // Execute query to check for duplicate transaction in table while ($row = mysql_fetch_array($duplicate)) { echo $row['docno']."<br/>"; echo $row['fdate']."<br/>"; echo $row['ftime']."<br/>"; echo $row['vegregno']."<br/>"; echo $row['direction']."<br/>"; echo $row['grossmass']."<br/>"; } Note: I confirm MySQL connection string/query in SELECT statement is valid and I have connection to the table for other objectives. However, I keep getting the below error for the stated code shown in this post. My question is, "what arguements are invalid - causing this error - as I confirmed the actual db table field names, the table connection, etc... are all valid? Error which is at the "WHILE" loop line of code: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource ?????????? :-\ Quote Link to comment https://forums.phpfreaks.com/topic/219955-mysql-query-error-supplied-argument-is-not-a-valid/ Share on other sites More sharing options...
Pikachu2000 Posted November 26, 2010 Share Posted November 26, 2010 $duplicate = mysql_query(rcheck); rcheck isn't a query string, $rcheck is . . . Quote Link to comment https://forums.phpfreaks.com/topic/219955-mysql-query-error-supplied-argument-is-not-a-valid/#findComment-1140122 Share on other sites More sharing options...
n1concepts Posted November 26, 2010 Author Share Posted November 26, 2010 Thanks for pointing out syntax issue - i corrected but same error. It's obvious their is another syntax error somewhere but I haven't been able to find it. Appreciate review. Quote Link to comment https://forums.phpfreaks.com/topic/219955-mysql-query-error-supplied-argument-is-not-a-valid/#findComment-1140125 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.