Hello guys, last time I learn php and make some scripts that work on my localhost, but not in a hosting which I use. Example:
checklogin.php:
<?php
ob_start();
$host="";
$username="";
$password="";
$db_name="";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM members WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
while($row = mysql_fetch_array($result, MYSQL_BOTH)){
$myusername = $row['username'];
session_register('myusername');
$mypassowrd = $row['password'];
session_register('mypassword');
header("location:login_success.php");
exit();
}
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
?>
login_success.php:
<?php
$host="";
$username="";
$password="";
$db_name="";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
$myusername = preg_replace('#(^A-Za-z0-9)#i', '', $_SESSION["myusername"]);
$mypassword = preg_replace('#(^A-Za-z0-9)#i', '', $_SESSION["mypassword"]);
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==0){
echo "not in db";
exit();
}
?>
Log of the serv is:
PHP Warning: Unknown: open(/var/php_sessions/sess_4a6f1b2dc34d7f3828d2692e924f4ad9, O_RDWR) failed: No such file or directory (2) in Unknown on line 0
PHP Warning: Unknown: Failed to write session data (files). Please verify
Where is the problem? And all gd scripts don't work, but server use latest gd libary :/
For example I use the exmaple of php.net:
<?php
// File and new size
$filename = 'test.jpg';
$percent = 0.5;
// Content type
header('Content-Type: image/jpeg');
// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;
// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// Output
imagejpeg($thumb);
?>
Thanks a lot for any help! Have a nice day