ccrevcypsys Posted January 2, 2008 Share Posted January 2, 2008 and i dont know why. Here is the hole page of code. I dont know why it isnt going... <?php if($_POST['email']==TRUE){ //Check if already logged in $query = "SELECT * FROM `sessions` WHERE customer_id = 36"; $result = mysql_query($query)or die(mysql_error()."error 1"); $row = mysql_fetch_array($result, MYSQL_NUM)or die(mysql_error()."error 2"); if($row==FALSE){ $querys = "SELECT customer_id, firstName FROM customer WHERE email = '".$_POST['email']."' AND password='".$_POST['password']."'"; $results = mysql_query($querys)or die(mysql_error()."error 3"); $rows = mysql_fetch_array($results, MYSQL_ASSOC)or die(mysql_error()."error 4"); $login = $_POST['email']; if($rows){ $sessId = rand(50,1000); $insert = mysql_query("INSERT INTO sessions (sessId,customer_id,timeStart,timeLast) VALUES (".$sessId.",".$row[0].", ".date('his').",".date('his').")")or die(mysql_error()); if($insert==TRUE){ setcookie("sessId", $sessId, time()+3600); header("Location: index.php?p=V"); } } }else{ echo "Already Logged in... <br /> Click Here To Destroy This Session!"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/84173-solved-query-statement-not-working/ Share on other sites More sharing options...
revraz Posted January 2, 2008 Share Posted January 2, 2008 I see 3 queries in that code Quote Link to comment https://forums.phpfreaks.com/topic/84173-solved-query-statement-not-working/#findComment-428477 Share on other sites More sharing options...
PHP_PhREEEk Posted January 2, 2008 Share Posted January 2, 2008 I see 3 queries in that code  and no definition of what 'not working' means...  PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/84173-solved-query-statement-not-working/#findComment-428479 Share on other sites More sharing options...
ccrevcypsys Posted January 2, 2008 Author Share Posted January 2, 2008 sorry about that i meant this one isnt working  $row = mysql_fetch_array($result, MYSQL_NUM)or die(mysql_error()."error 2");  the first one it just tells me "error 2" and no mysql error... Quote Link to comment https://forums.phpfreaks.com/topic/84173-solved-query-statement-not-working/#findComment-428481 Share on other sites More sharing options...
revraz Posted January 2, 2008 Share Posted January 2, 2008 Is there a customer_id 36 in your sessions table? Do you have a connection to your DB? Quote Link to comment https://forums.phpfreaks.com/topic/84173-solved-query-statement-not-working/#findComment-428482 Share on other sites More sharing options...
ccrevcypsys Posted January 2, 2008 Author Share Posted January 2, 2008 ok well i fugured it out.. so it works now but what i need to do is set up a checking system for the login. But i cant get it. so heres what i have and it doesnt work how i want it to ( i want it so that when someone tries to login and there is already a session i will have it update the information in the db with the new sess data and the new times instead of making 1.3 billion of them over the course of the next 2 weeks lol. so if you can help it would be awsome ) <?php if($_POST['email']==TRUE){ //Check if already logged in $query = "SELECT * FROM `sessions`"; $result = mysql_query($query)or die(mysql_error()."error 1"); $row = mysql_fetch_array($result, MYSQL_ASSOC)or die(mysql_error()."error 3"); if($row == TRUE && $row['customer_id']=="36"){ echo "Already Logged In Click Here To Destroy All Sessions."; }else{ $querys = "SELECT * FROM customer WHERE email = '".$_POST['email']."' AND password='".$_POST['password']."'"; $results = mysql_query($querys)or die(mysql_error()."error 1"); $rows = mysql_fetch_array($results, MYSQL_ASSOC)or die(mysql_error()."error 2"); $login = $_POST['email']; if($rows){ $sessId = rand(50,1000); $insert = mysql_query("INSERT INTO sessions (sessId,customer_id,timeStart,timeLast) VALUES (".$sessId.",".$rows['customer_id'].", ".date('his').",".date('his').")")or die(mysql_error()); if($insert==TRUE){ setcookie("sessId", $sessId, time()+3600); setcookie("customer_id", $rows['customer_id'], time()+3600); header("Location: index.php?p=V"); } } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/84173-solved-query-statement-not-working/#findComment-428512 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.