freddyw Posted July 19, 2009 Share Posted July 19, 2009 Can anybody see why the query isnt executing. I cant see the problem. Im new to PHP im using PHP5 and not mysql. any ideas? <?php $username = (isset($_POST['username'])) ? pg_escape_string($_POST['username']) : ""; $password = (isset($_POST['password'])) ? pg_escape_string($_POST['password']) : ""; $referer = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : "noreferer"; #this will make user return to login page if a field is left empty if ( ( !$username ) or (!$password) ) { header ( "location:$referer" ); exit(); } $conn = @pg_connect("connection details hidden"); $psql="select * from users where username =\"$username\" and password =\"$password\""; $rs = @pg_query ($psql, $conn) or die ("could not execute query"); #get number of rows that match username and password $num = pg_num_rows($rs); #if there is a match log in successful if ( $num !=0 ) { $msg = "Welcome $username - You are logged in"; } else #return to log in page { header ( "location:$referer" ); exit(); } ?> <html> <head><title>You are logged in</title></head> <body> <? echo ( $msg ); ?> </body> <html> any help will be apperciated Link to comment https://forums.phpfreaks.com/topic/166520-cant-execute-query/ Share on other sites More sharing options...
Gighalen Posted July 19, 2009 Share Posted July 19, 2009 How can you not be using MySQL? Link to comment https://forums.phpfreaks.com/topic/166520-cant-execute-query/#findComment-878133 Share on other sites More sharing options...
mmarif4u Posted July 19, 2009 Share Posted July 19, 2009 Oh my dear... you have to install MySQL too. Link to comment https://forums.phpfreaks.com/topic/166520-cant-execute-query/#findComment-878147 Share on other sites More sharing options...
PFMaBiSmAd Posted July 19, 2009 Share Posted July 19, 2009 Don't use @ in code to hide errors, ever. There is absolutely no reason to ever use @ in code. In your code they are probably hiding error messages that would help point out why your code is not working. Also, when learning php (or learning anything new in php), developing php code, or debugging php code, you should have error_reporting set to E_ALL and display_errors set to ON in your php.ini to get php to help you. Link to comment https://forums.phpfreaks.com/topic/166520-cant-execute-query/#findComment-878152 Share on other sites More sharing options...
freddyw Posted July 19, 2009 Author Share Posted July 19, 2009 im not using MySql because im using pgsql, and i prefere putty for that Link to comment https://forums.phpfreaks.com/topic/166520-cant-execute-query/#findComment-878302 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.