Jump to content


Photo

Login Page


  • Please log in to reply
1 reply to this topic

#1 aenigma

aenigma
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 05 May 2006 - 03:34 AM

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] <?
$db_host = "localhost";
$db_username = "aenigma_josh";
$db_password = "strg388";
$db_name = "aenigma_joshs";

if ( isset( $_POST["Submit"] ) ) {
if ( !$link = mysql_connect($db_host, $db_username, $db_password)) {
die( "Unable to connect to MySQL Server." );
}

if ( !$dbselect = mysql_select_db($db_name, $link)) {
die( "Unable to select MySQL database." );
}

if ( isset( $_POST["username"] ) ) {
$username = $_POST["username"];
}
else {
die( "You did not enter a username." );
}

if ( isset( $_POST["password"] ) ) {
$password = $_POST["password"];
}
else {
die( "You did not enter a password." );
}

$query = "SELECT * FROM users WHERE username = '". mysql_real_escape_string($username) ."' AND password = '". md5($password) ."' LIMIT 1";

if ( !$result = mysql_query($query, $link)) {
die( "Unable to run SQL query." );
}


if ( mysql_num_rows( $result ) != 1 ) {
die( "Invalid username or password" );
}
else {
$userinfo = mysql_fetch_array( $result );
}

mysql_free_result( $result );
$day = date('d', time());
$month = date('m', time());
$year = date('Y', time());
$hour = date('H', time());
$min = date('i', time());
$sec = date('s', time());
$uid1 = md5(uniqid(rand(), true));
$uid2 = md5(uniqid(rand(), true));
$uid3 = md5(uniqid(rand(), true));
$sessionid = "'". $uid2 . $yeah . $sec ."'-'". day . $hour . $uid3 ."'-'". $min . $uid1 . $month ."'";
$sname = session_name("$sessionid");
session_start($sname);
$_session['username'] = $userinfo[username];
$_session['displayname'] = $userinfo[displayname];
$_session['email'] = $userinfo[email];
$next = "index.php?page=news";
Header('Location: $next');
}

?>[/quote]

Says "Unable to Run SQL Query" ANy ideas? lol.

#2 cunoodle2

cunoodle2
  • Members
  • PipPipPip
  • Advanced Member
  • 602 posts

Posted 05 May 2006 - 05:35 AM

Try changing this...


 if ( !$result = mysql_query($query, $link)) {
die( "Unable to run SQL query." );
}

To this...
if (!($result = mysql_query($query, $link)))
{
die( "Unable to run SQL query." );
}

If that does not work then also try this...
if (!($result = mysql_query($query)))
{
die( "Unable to run SQL query." );
}

Take a look there and then let us know.

If the code was working and now it's not, something changed. Did you change any code?

yeah, just a little bit, I am trying to start from beginning and trace my steps to see what i did wrong unless you see it.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users