Jump to content

[SOLVED] mysql_fetch_array() I did something wrong


Yeodan

Recommended Posts

<?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 :(

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);

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'];

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.