aenigma Posted May 5, 2006 Share Posted May 5, 2006 [!--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. Quote Link to comment Share on other sites More sharing options...
cunoodle2 Posted May 5, 2006 Share Posted May 5, 2006 Try changing this...[code] if ( !$result = mysql_query($query, $link)) {die( "Unable to run SQL query." );}[/code]To this...[code]if (!($result = mysql_query($query, $link))){die( "Unable to run SQL query." );}[/code]If that does not work then also try this...[code]if (!($result = mysql_query($query))){die( "Unable to run SQL query." );}[/code]Take a look there and then let us know. 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.