vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 ok i put "mysql_error();" and it says error on line 48 that there is no $end.. does anyone know the code to end it? Quote Link to comment Share on other sites More sharing options...
derrick1123 Posted March 12, 2008 Share Posted March 12, 2008 mysql_close(); Weird, I didn't think it would require this. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 I don't know why but: $result=mysql_query($sql); Shouldn't that be: $result=mysql_query("$sql"); Â ??? Â That would make it read the string "$sql" not the query that the var contains. Â Â Quote Link to comment Share on other sites More sharing options...
derrick1123 Posted March 12, 2008 Share Posted March 12, 2008 I don't know why but: $result=mysql_query($sql); Shouldn't that be: $result=mysql_query("$sql"); Â ??? Â That would make it read the string "$sql" not the query that the var contains. Â Â OH, ok thanks! Quote Link to comment Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 mysql_close(); Weird, I didn't think it would require this. Â that didnt do anything.... but this is the error "Parse error: syntax error, unexpected $end in /home/pacifij1/public_html/bluewavesvirtual/checklogin.php on line 48" Quote Link to comment Share on other sites More sharing options...
derrick1123 Posted March 12, 2008 Share Posted March 12, 2008 Can you post your checklogin.php now? Quote Link to comment Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 ok i made a test account for you guys to check it out...  here is the file.. http://bluewavesvirtual.com/index1.php  user is BWA1001 password is 833699 Quote Link to comment Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 ok i made a test account for you guys to check it out...  here is the file.. http://bluewavesvirtual.com/index1.php  user is BWA1001 password is 833699  We need your current checklogin.php script, we can't fix this by just visiting the page Quote Link to comment Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 that first page was the script Quote Link to comment Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 that first page was the script  Any changes you made might have caused the error, post your current page for the checklogin.php Quote Link to comment Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 ok <?php $host="localhost"; // Host name $username="pacifij1_blue"; // Mysql username $password="8336994895"; // Mysql password $db_name="pacifij1_blue"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from signup form $callsign = $_POST['callsign']; $pwd = $_POST['pwd']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $sql="SELECT * FROM pilot WHERE callsign='$callsign' and pwd='$pwd'"; $result=mysql_query($sql) or die(mysql_error()); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count<0){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("callsign"); session_register("pwd"); session_register("first_name"); session_register("last_name"); header("location:login_success.php"); } else { mysql_error(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Loading</title> </head> <body> </body> </html> <?php mysql_close(); ?> Quote Link to comment Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 try <?php $host="localhost"; // Host name $username="pacifij1_blue"; // Mysql username $password="8336994895"; // Mysql password $db_name="pacifij1_blue"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from signup form $callsign = $_POST['callsign']; $pwd = $_POST['pwd']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $sql="SELECT * FROM pilot WHERE callsign='$callsign' and pwd='$pwd'"; $result=mysql_query($sql) or die(mysql_error()); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count<0){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("callsign"); session_register("pwd"); session_register("first_name"); session_register("last_name"); header("location:login_success.php"); } else { mysql_error(); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Loading</title> </head> <body> </body> </html> <?php mysql_close(); ?> Â edit: You forgot a "}" closing bracket after the ELSE Quote Link to comment Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 IT WORKS NOW.. but its not redirecting to the header Quote Link to comment Share on other sites More sharing options...
derrick1123 Posted March 12, 2008 Share Posted March 12, 2008 Change: header("location:login_success.php"); to: echo "<head><title><meta http-equiv='refresh' content='5;url=login_success.php'></title></head>"; Quote Link to comment Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 Nope.. its just showing a white page.. you guys can check.. i posted the user and password Quote Link to comment Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 Try  <?php $host="localhost"; // Host name $username="pacifij1_blue"; // Mysql username $password="8336994895"; // Mysql password $db_name="pacifij1_blue"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from signup form $callsign = $_POST['callsign']; $pwd = $_POST['pwd']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $sql="SELECT * FROM pilot WHERE callsign='$callsign' and pwd='$pwd'"; $result=mysql_query($sql) or die(mysql_error()); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count<0){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("callsign"); session_register("pwd"); session_register("first_name"); session_register("last_name"); header("location:login_success.php"); echo 'Login Worked'; } else { mysql_error(); echo 'Login Didnt Work'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Loading</title> </head> <body> </body> </html> <?php mysql_close(); ?> Quote Link to comment Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 Login Didnt Work Quote Link to comment Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 Login Didnt Work  Thats because of the  if($count<0){  *dirty look to derrick * jk  Try  <?php $host="localhost"; // Host name $username="pacifij1_blue"; // Mysql username $password="8336994895"; // Mysql password $db_name="pacifij1_blue"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from signup form $callsign = $_POST['callsign']; $pwd = $_POST['pwd']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $sql="SELECT * FROM pilot WHERE callsign='$callsign' and pwd='$pwd'"; $result=mysql_query($sql) or die(mysql_error()); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("callsign"); session_register("pwd"); session_register("first_name"); session_register("last_name"); header("location:login_success.php"); echo 'Login Worked'; } else { mysql_error(); echo 'Login Didnt Work'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Loading</title> </head> <body> </body> </html> <?php mysql_close(); ?>  That little part basically means if $count echos any number under 0, then log the user in Quote Link to comment Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 still didnt work Quote Link to comment Share on other sites More sharing options...
derrick1123 Posted March 12, 2008 Share Posted March 12, 2008 My bad lol  You might have to use: session_start(); Quote Link to comment Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 still didnt work  We prevented a bug that may occur in the future, so lets give a pat on our backs. You should print out the username and password from the FORM, and the DB and see if they equal each other...  <?php $host="localhost"; // Host name $username="pacifij1_blue"; // Mysql username $password="8336994895"; // Mysql password $db_name="pacifij1_blue"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from signup form $callsign = $_POST['callsign']; $pwd = $_POST['pwd']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $sql="SELECT * FROM pilot WHERE callsign='$callsign' and pwd='$pwd'"; $result=mysql_query($sql) or die(mysql_error()); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row $row = mysql_fetch_array($result); echo 'Username Tried: ' .$callsign; echo 'Password Tried: ' .$pwd.'<br>'; echo 'Username DB: ' .$row['pwd']; echo 'Password DB: ' .$row['callsign'].'<br>'; if($count > 0){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("callsign"); session_register("pwd"); session_register("first_name"); session_register("last_name"); header("location:login_success.php"); echo 'Login Worked'; } else { mysql_error(); echo 'Login Didnt Work'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Loading</title> </head> <body> </body> </html> <?php mysql_close(); ?> Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted March 12, 2008 Share Posted March 12, 2008 i don't bother with counts.. Â i just would do... Â Â $sql="SELECT `id` FROM pilot WHERE callsign='$callsign' and pwd='$pwd'"; $result=mysql_query($sql) or die(mysql_error()); $id= mysql_fetch_array($result); Â if(empty($id['id'])){ echo failed} Â if(strlen($id['id']) > 0){ log in } Â it doesn't count rows... so if there was more than 1 password and username the same i'd be screwed... but i check for existing user names at registration, so that shouldn't be a problem Quote Link to comment Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 i don't bother with counts..  i just would do...   $sql="SELECT `id` FROM pilot WHERE callsign='$callsign' and pwd='$pwd'"; $result=mysql_query($sql) or die(mysql_error()); $id= mysql_fetch_array($result);  if(empty($id['id'])){ echo failed}  if(strlen($id['id']) > 0){ log in }  it doesn't count rows... so if there was more than 1 password and username the same i'd be screwed... but i check for existing user names at registration, so that shouldn't be a problem  You would prevent that at the registration process, and your method takes a lifetime Quote Link to comment Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 ok php sinsi i did what you said and it did this Username Tried: BWA1001Password Tried: 833699 Username DB: 833699Password DB: BWA1001 Â Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home/pacifij1/public_html/bluewavesvirtual/checklogin.php:27) in /home/pacifij1/public_html/bluewavesvirtual/checklogin.php on line 36 Â Warning: Cannot modify header information - headers already sent by (output started at /home/pacifij1/public_html/bluewavesvirtual/checklogin.php:27) in /home/pacifij1/public_html/bluewavesvirtual/checklogin.php on line 40 Login Worked Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0 Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted March 12, 2008 Share Posted March 12, 2008 php sensi, my method or his??? 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.