[PHP] RE: Invalid Argument ??? Not sure how to debug this
Try ... If ($result = ...) { ... ... } else echo(mysql_error()); I always do querying like this anyway (without the error echo in live stuff obviously) Tim Ward Internet Chess www.chessish.com http://www.chessish.com -- From: Daniel Negron/KBE [SMTP:[EMAIL PROTECTED]] Sent: 17 March 2002 08:38 To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Invalid Argument ??? Not sure how to debug this Hi all and Good Morning. I have been struggling with this code: I was wondering if someone could lend me a hand. I am working with this code and can't get the error to disappear. After running I get |--- --| | Warning: Supplied argument is not a valid MySQL result resource in C:\My Documents\My | | Webs\php\TMPibtpit3zq0.php on line 12 | |--- --| Line 12 happens to be the WHILE statement. I am not sure if it is the while statement or the results its looking for. TIA So far, i havent been able to sleep atleast until I get this. html ? if (isset($searchstring)) { $db = mysql_connect(localhost,webuser,); mysql_select_db(cd_collection,$db); $sql= SELECT * FROM cd_list WHERE $searchstring LIKE '%searchstring%' ORDER BY artist ASC; $result = mysql_query($sql,$db); echo TABLE BORDER=2; echo trtdbArtist/btdbTitle/btdbOptions/b/tr; while ($myrow = mysql_fetch_array($result)) { echo trtd.$myrow[artist].td.$myrow[title]; echo tda href=\edit.php?id=.$myrow[cd_id]. \View/a; } echo /TABLE; } else { ? form method=POST action=? $PHP_SELF ? table border=2 cellspacing=2 trtdInsert Your Search String Here./td tdSearch Type/td/tr tr tdinput type=text name=searchstring size=28/td tdselect size=1 name=searchtype option selected value=artistArtist/option option value=titleTitle/option option value=categoryCategory/option /select/td /tr /table pinput type = submit value=Submit name=B1 input type=reset value=Reset/p /form ? } ? /html **DAN** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Invalid Argument ??? Not sure how to debug this
Daniel, $myrow[artist] and $myrow[title] might be a good place to start. It looks like all your ; are in place. I don't think you can place inside [] like that: echo trtd.$myrow[artist].td.$myrow[title]; I have been struggling with this code: I was wondering if someone could lend me a hand. Line 12 happens to be the WHILE statement. I am not sure if it is the while statement or the results its looking for. TIA So far, i havent been able to sleep atleast until I get this. html ? if (isset($searchstring)) { $db = mysql_connect(localhost,webuser,); mysql_select_db(cd_collection,$db); $sql= SELECT * FROM cd_list WHERE $searchstring LIKE '%searchstring%' ORDER BY artist ASC; $result = mysql_query($sql,$db); echo TABLE BORDER=2; echo trtdbArtist/btdbTitle/btdbOptions/b/tr; while ($myrow = mysql_fetch_array($result)) { echo trtd.$myrow[artist].td.$myrow[title]; echo tda href=\edit.php?id=.$myrow[cd_id]. \View/a; } echo /TABLE; } else { ? form method=POST action=? $PHP_SELF ? table border=2 cellspacing=2 trtdInsert Your Search String Here./td tdSearch Type/td/tr tr tdinput type=text name=searchstring size=28/td tdselect size=1 name=searchtype option selected value=artistArtist/option option value=titleTitle/option option value=categoryCategory/option /select/td /tr /table pinput type = submit value=Submit name=B1 input type=reset value=Reset/p /form ? } ? /html **DAN** -- John Taylor-Johnston - ' ' ' Collège de Sherbrooke: ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/ - Université de Sherbrooke: http://compcanlit.ca/ 819-569-2064 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Invalid Argument ??? Not sure how to debug this (RESOLVED)
I guess I should have walked away then come back to it. I was just trying to get this code to work with little effort as possible. I guess, I should have done it right in the first place. What I didn't realize is that I mistakenly made $sql= SELECT * FROM cd_list WHERE $searchstring LIKE '%searchstring%' I should have made $searchstring to $searchtype that resolved the initial problem with the code. Thank you Nathan. I guess from now on I wont be trying to shortcut coding Also thank you all for you assistance in this matter. Thank You Daniel Negrón Lotus Notes Administrator / Developer KB Electronics, Inc. 954.346.4900x122 http://www.kbelectronics.com Nathan etherwolf@sop To: Daniel Negron/KBE [EMAIL PROTECTED] ris.net cc: Subject: Re: Invalid Argument ??? Not sure how to debug this 03/17/2002 04:54 PM The simplest thing to do to narrow down the source of the problem is change line 9 to read: $result = mysql_query($sql,$db) or exit(mysql_error().BR.$sql); This will halt the script before it even gets to line 12 and give you the error MySQL had as well as the query that was sent to the database. This is a very good practice for the rest of your php code. Your ...LIKE %searchstring%... bit with no $ will give you all rows matching: searchstring* I take it that is not your intention... You probably need to change that to: ...LIKE %.$searchstring.%... Also, why are both your column name and desired value the same? Should you be selecting WHERE columnname LIKE %$searchstring%? If you are still unsuccessful in resolving this, I'll help out however I can. Cheers, # Nathan - Original Message - From: Daniel Negron/KBE [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Sunday, March 17, 2002 1:38 AM Subject: Invalid Argument ??? Not sure how to debug this Hi all and Good Morning. I have been struggling with this code: I was wondering if someone could lend me a hand. I am working with this code and can't get the error to disappear. After running I get |-| | Warning: Supplied argument is not a valid MySQL result resource in C:\My Documents\My | | Webs\php\TMPibtpit3zq0.php on line 12 | |-| Line 12 happens to be the WHILE statement. I am not sure if it is the while statement or the results its looking for. TIA So far, i havent been able to sleep atleast until I get this. html ? if (isset($searchstring)) { $db = mysql_connect(localhost,webuser,); mysql_select_db(cd_collection,$db); $sql= SELECT * FROM cd_list WHERE $searchstring LIKE '%searchstring%' ORDER BY artist ASC; $result = mysql_query($sql,$db); echo TABLE BORDER=2; echo trtdbArtist/btdbTitle/btdbOptions/b/tr; while ($myrow = mysql_fetch_array($result)) { echo trtd.$myrow[artist].td.$myrow[title]; echo tda href=\edit.php?id=.$myrow[cd_id]. \View/a; } echo /TABLE; } else { ? form method=POST action=? $PHP_SELF ? table border=2 cellspacing=2 trtdInsert Your Search String Here./td tdSearch Type/td/tr tr tdinput type=text name=searchstring size=28/td tdselect size=1 name=searchtype option selected value=artistArtist/option option value=titleTitle/option option value=categoryCategory/option /select/td /tr /table pinput type = submit value=Submit name=B1 input type=reset value=Reset/p /form ? } ? /html **DAN** - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: