Yeodan Posted March 23, 2009 Share Posted March 23, 2009 <?php $con = mysql_connect("localhost","***","***"); if (!$con) { die('Could not connect: ' . mysql_error()); } $account = $_POST["acc"]; $password = $_POST["pass"]; mysql_select_db("players", $con); $result = mysql_query("SELECT * FROM players WHERE PlayerName=" . $account); $row = mysql_fetch_array($result); echo $row['PlayerName'] . " " . $row['PlayerPass']; ?> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\SuperSecret\PHP\wamp\www\login2.php on line 17 What did I miss? I can't find it Link to comment https://forums.phpfreaks.com/topic/150752-solved-mysql_fetch_array-i-did-something-wrong/ Share on other sites More sharing options...
Yesideez Posted March 23, 2009 Share Posted March 23, 2009 $result = mysql_query("SELECT * FROM players WHERE PlayerName='" . $account . "'"); Link to comment https://forums.phpfreaks.com/topic/150752-solved-mysql_fetch_array-i-did-something-wrong/#findComment-791990 Share on other sites More sharing options...
Yesideez Posted March 23, 2009 Share Posted March 23, 2009 btw, if those are your database connection details I'd edit your post and remove them Link to comment https://forums.phpfreaks.com/topic/150752-solved-mysql_fetch_array-i-did-something-wrong/#findComment-791991 Share on other sites More sharing options...
Yeodan Posted March 23, 2009 Author Share Posted March 23, 2009 btw, if those are your database connection details I'd edit your post and remove them nah, nothing important now I get this: Parse error: parse error in D:\SuperSecret\PHP\wamp\www\login2.php on line 16 Link to comment https://forums.phpfreaks.com/topic/150752-solved-mysql_fetch_array-i-did-something-wrong/#findComment-791992 Share on other sites More sharing options...
lonewolf217 Posted March 23, 2009 Share Posted March 23, 2009 I think this normally happens when there is a problem with either your DB connection or your SQL query. mysql_select_db("players", $con) or die (mysql_error()); $result = mysql_query("SELECT * FROM players WHERE PlayerName=" . $account) or die (mysql_error()); $row = mysql_fetch_array($result); Link to comment https://forums.phpfreaks.com/topic/150752-solved-mysql_fetch_array-i-did-something-wrong/#findComment-791993 Share on other sites More sharing options...
Yeodan Posted March 23, 2009 Author Share Posted March 23, 2009 bah I keep making stupid mistakes now Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\SuperSecret\PHP\wamp\www\login2.php on line 17 Link to comment https://forums.phpfreaks.com/topic/150752-solved-mysql_fetch_array-i-did-something-wrong/#findComment-791994 Share on other sites More sharing options...
Yeodan Posted March 23, 2009 Author Share Posted March 23, 2009 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 ''' at line 1 hmm Link to comment https://forums.phpfreaks.com/topic/150752-solved-mysql_fetch_array-i-did-something-wrong/#findComment-791997 Share on other sites More sharing options...
Yeodan Posted March 23, 2009 Author Share Posted March 23, 2009 I hate php stupid " and ' and ; Link to comment https://forums.phpfreaks.com/topic/150752-solved-mysql_fetch_array-i-did-something-wrong/#findComment-791999 Share on other sites More sharing options...
Yesideez Posted March 23, 2009 Share Posted March 23, 2009 Try this... <?php $con = mysql_connect("localhost","***","***") or die('Unable to connect: '.mysql_error()); mysql_select_db('players'); $account = $_POST['acc']; $password = $_POST['pass']; $result = mysql_query("SELECT * FROM players WHERE PlayerName='".$account."'"); $row = mysql_fetch_array($result); echo $row['PlayerName'] . " " . $row['PlayerPass']; ?> Link to comment https://forums.phpfreaks.com/topic/150752-solved-mysql_fetch_array-i-did-something-wrong/#findComment-792004 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.