jonoc33 Posted December 26, 2007 Share Posted December 26, 2007 $con = mysql_connect(DB_SERVER,DB_USER,DB_PASS); mysql_select_db(DB_NAME, $con); $results = mysql_query("SELECT tacticname, tactics FROM ".TBL_TACTICS." WHERE tacticname=".$_POST['tacticname'].""); $values = mysql_fetch_array($results); $value = $values['tactics']; Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/jonoc33/public_html/clan/alpha/admin/tacticedit1.php on line 19 the bit that has the mysql_fetch_array is line 19. This error just popped up, but I can't seem to figure out why it is occuring. The mysql query looks fine to me, and the variables are fine. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted December 26, 2007 Share Posted December 26, 2007 I wonder why there is such a big white space in your post. Try: <?php mysql_connect(DB_SERVER,DB_USER,DB_PASS); mysql_select_db(DB_NAME); $results = mysql_query("SELECT tacticname, tactics FROM ".TBL_TACTICS." WHERE tacticname=".$_POST['tacticname'].""); $values = mysql_fetch_array($results); $value = $values['tactics']; ?> Quote Link to comment Share on other sites More sharing options...
trq Posted December 26, 2007 Share Posted December 26, 2007 You need to check your queries for success prior to attempting using any results. <?php $con = mysql_connect(DB_SERVER,DB_USER,DB_PASS); mysql_select_db(DB_NAME, $con); if ($result = mysql_query("SELECT tacticname, tactics FROM ".TBL_TACTICS." WHERE tacticname = '{$_POST['tacticname']}')) { if (mysql_num_rows($result)) { $values = mysql_fetch_array($results); $value = $values['tactics']; } else { echo "no results found"; } } else { echo mysql_error(); } ?> I also fixed the errors in your query. Quote Link to comment Share on other sites More sharing options...
jonoc33 Posted December 26, 2007 Author Share Posted December 26, 2007 EDITED: Parse error: syntax error, unexpected '{' in /home/jonoc33/public_html/clan/alpha/admin/tacticedit1.php on line 17 Line 20: $value = $values['tactics']; Current code: $con = mysql_connect(DB_SERVER,DB_USER,DB_PASS); mysql_select_db(DB_NAME, $con); if ($result = mysql_query("SELECT tacticname, tactics FROM ".TBL_TACTICS." WHERE tacticname = '{$_POST['tacticname']}')") { if (mysql_num_rows($result)) { $values = mysql_fetch_array($results); $value = $values['tactics']; } else { echo "no results found"; } } else { echo mysql_error(); } Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted December 26, 2007 Share Posted December 26, 2007 Find this line: if ($result = mysql_query("SELECT tacticname, tactics FROM ".TBL_TACTICS." WHERE tacticname = '{$_POST['tacticname']}')") { Change it to: if ($result = mysql_query("SELECT tacticname, tactics FROM ".TBL_TACTICS." WHERE tacticname = '{$_POST['tacticname']}'")) { Quote Link to comment Share on other sites More sharing options...
jonoc33 Posted December 26, 2007 Author Share Posted December 26, 2007 Ok i reverted back to my old code and put in mysql_error(). Unknown column 'fgfdgs' in 'where clause' I've found that fgfdgs is the value of the 'tacticname' field. What does where clause mean? Quote Link to comment Share on other sites More sharing options...
jonoc33 Posted December 26, 2007 Author Share Posted December 26, 2007 Changed to new code now with that code change. The page now displays, but I still get the Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/jonoc33/public_html/clan/alpha/admin/tacticedit1.php on line 19 error Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted December 26, 2007 Share Posted December 26, 2007 Ok i reverted back to my old code and put in mysql_error(). Unknown column 'fgfdgs' in 'where clause' I've found that fgfdgs is the value of the 'tacticname' field. What does where clause mean? When you say "SELECT table_columns FROM table_name WHERE table_column=$value" that's the WHERE clause. Apparently, you're calling the table column fgfdgs and it doesn't exist. Quote Link to comment Share on other sites More sharing options...
jonoc33 Posted December 26, 2007 Author Share Posted December 26, 2007 Strange, i'm not though... Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted December 26, 2007 Share Posted December 26, 2007 Check your database via phpMyAdmin and check if the column does exist. Also, make sure you're calling the correct table for the column and there are no misspellings. We can't verify if that column exists for you. Quote Link to comment Share on other sites More sharing options...
jonoc33 Posted December 26, 2007 Author Share Posted December 26, 2007 that gibberish table does not exist, tacticname does exist and so does tactics, and they are spelt right. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted December 26, 2007 Share Posted December 26, 2007 that gibberish table does not exist, tacticname does exist and so does tactics, and they are spelt right. Okay, Is that table suppose to exist or is it just an example? I'm terribly sorry here, but I'm a bit confused. Can you please post the error you have now again? Quote Link to comment Share on other sites More sharing options...
jonoc33 Posted December 26, 2007 Author Share Posted December 26, 2007 Ok, basically there are 3 fields. Tacticname, tactics and map. the Tacticname field contains the gibberish thing that I said earlier, tactics contains what comes out of the mysql and map is out of the picture. When I open up the page, it shows everything but it will not echo $value because it shows this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/jonoc33/public_html/clan/alpha/admin/tacticedit1.php on line 19 Line 19 is this: $values = mysql_fetch_array($results); My current code: $con = mysql_connect(DB_SERVER,DB_USER,DB_PASS); mysql_select_db(DB_NAME, $con); if ($results = mysql_query("SELECT id, tacticname, tactics FROM ".TBL_TACTICS." WHERE id = '{$_POST['id']}'")) { if (mysql_num_rows($results)) { $values = mysql_fetch_array($results); $value = stripslashes($values['tactics']); } else { echo "no results found"; } } else { echo mysql_error(); } Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted December 26, 2007 Share Posted December 26, 2007 Okay, what's id? You selected id, but you didn't tell me you have an id column. ??? Quote Link to comment Share on other sites More sharing options...
jonoc33 Posted December 26, 2007 Author Share Posted December 26, 2007 yeah there is an auto-increment id column Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted December 26, 2007 Share Posted December 26, 2007 Okay. Can I get your entire PHP code including the form you used? Quote Link to comment Share on other sites More sharing options...
jonoc33 Posted December 26, 2007 Author Share Posted December 26, 2007 I fixed it somehow, did something to the code and it worked. Thanks for all your help. Quote Link to comment 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.