rezwanh001 / Online-Voting-System-using-php-and-mysql

php and mysql project
138 stars 117 forks source link

its showing syntax error after changing mysql to mysqli in whole code in admin/checklogin.php #19

Open deepthi2514 opened 4 years ago

deepthi2514 commented 4 years ago

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\Online-Voting-System-using-php-and-mysql-master(github)(ex)\Online-Voting-System-using-php-and-mysql-master\online_voting\admin\checklogin.php on line 36

Darlenequame commented 4 years ago

change the code with this.

`<!DOCTYPE html>

escape_string($_POST['myusername']); $mypassword = $mysqli->escape_string($_POST['mypassword']); $sql="SELECT * FROM $tbl_name WHERE email='$myusername' and password='$encrypted_mypassword'" or die(mysql_error()); $result= $mysqli->query($sql); $count=mysqli_num_rows($result); if($count==1){ // $user = $result->fetch_assoc(); // $_SESSION['admin_id'] = $user['admin_id']; if(isset($_POST['remember'])) { setcookie('$email',$_POST['myusername'], time()+30*24*60*60); // 30 days setcookie('$pass', $_POST['mypassword'],time()+30*24*60*60); // 30 days $_SESSION['curname']=$myusername; $_SESSION['curpass']=$mypassword; $user = $result->fetch_assoc(); $_SESSION['admin_id'] = $user['admin_id']; header("Location:admin.php"); exit; } else { $log1=11; $_SESSION['log1'] = $log1; $_SESSION['curname']=$myusername; $_SESSION['curpass']=$mypassword; $user = $result->fetch_assoc(); $_SESSION['admin_id'] = $user['admin_id']; header("Location:admin.php"); exit; } } else { echo "


"; echo "

Wrong Username or Password

Return to login

"; } ob_end_flush(); ?> `
deepthi2514 commented 4 years ago

after changing to this code its showing this error Fatal error: Uncaught Error: Call to a member function escape_string() on null in C:\xampp\htdocs\Online-Voting-System-using-php-and-mysql-master(github)(ex)\Online-Voting-System-using-php-and-mysql-master\online_voting\admin\checklogin.php:24 Stack trace: #0 {main} thrown in C:\xampp\htdocs\Online-Voting-System-using-php-and-mysql-master(github)(ex)\Online-Voting-System-using-php-and-mysql-master\online_voting\admin\checklogin.php on line 24

deepthi2514 commented 4 years ago

Failed to connect to MySQL: Access denied for user 'my_user'@'localhost' (using password: YES) Fatal error: Uncaught Error: Call to a member function escape_string() on null in C:\xampp\htdocs\Online-Voting-System-using-php-and-mysql-master(github)(ex)\Online-Voting-System-using-php-and-mysql-master\online_voting\admin\checklogin.php:17 Stack trace: #0 {main} thrown in C:\xampp\htdocs\Online-Voting-System-using-php-and-mysql-master(github)(ex)\Online-Voting-System-using-php-and-mysql-master\online_voting\admin\checklogin.php on line 17

deepthi2514 commented 4 years ago

Failed to connect to MySQL: Access denied for user 'my_user'@'localhost' (using password: YES) Fatal error: Uncaught Error: Call to a member function escape_string() on null in C:\xampp\htdocs\Online-Voting-System-using-php-and-mysql-master(github)(ex)\Online-Voting-System-using-php-and-mysql-master\online_voting\checklogin.php:113 Stack trace: #0 {main} thrown in C:\xampp\htdocs\Online-Voting-System-using-php-and-mysql-master(github)(ex)\Online-Voting-System-using-php-and-mysql-master\online_voting\checklogin.php on line 113