Hi everybody,
would you please tell me what's wrong with this code
that generates the following error:
Warning: fopen(C:\Documents and Settings\Sando\Desktop\boys.gif) [function.fopen]: failed to open stream: No such file or directory in /home/domain/public_html/webs/divisions/chek.php on line 108
data inserted without any picture
although it works fine and great @ localhost
MySQL Server 5.1
Appache 2.2
PHP 5.2.11
and as I said just great
but on the server 'BLUEHOST' I get that error
help please:
<?php session_start();
// if session is not set redirect the user
if(empty($_SESSION['u_name'])){
header("Location:table.php");
}
include ("connect.php");
include ("function.php");
$agent=$_SESSION['u_name'];
$sql="SELECT * FROM tbl_user WHERE user_name='$agent' ";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$pri= $row['pri'];
If($pri ==1 || $pri ==3) {
GoTO("../log/cp.php");
}
$host="localhost";
$username="name";
$password="pass";
$db_name="db";
$tbl_name="teachers2";
//////////////////////////////////////////////////////////////
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$db_name")or die("cannot select DB");
//////////////////////////////////////////////////////////////
$N_Teacher = $_POST['N_Teacher'];
$N_Email = $_POST['N_Email'];
$N_Teacher = addslashes($N_Teacher);
$N_Email = addslashes($N_Email);
$N_date=date("d-m-y H:i:s");
$agent=$_SESSION['u_name'];
$division=$_POST['division'];
$divisionID=$_POST['divisionID'];
$position=$_POST['position'];
$positionID=$_POST['positionID'];
$employee=$_POST['employee'];
$wordcomm=$_POST['wordcomm'];
$N_Telefon=$_POST['N_Telefon'];
if (empty($N_Teacher) || empty($N_Email))
{
bad();
}
else {
good();
}
////////////////////////////////////
function bad(){
echo "<center><font color='ff0000' font face='Tahoma' size='2'><b>Please fill in both name and email</B></font></center>";
$htmlheader=InCludePageHtml("template/header.html");
eval("echo stripslashes(\"$htmlheader\");");
GoTO("add.php");
}
//////////////////////////////////////////////////////////////
function good(){
$N_Teacher = $_POST['N_Teacher'];
$N_Email = $_POST['N_Email'];
$N_Teacher = addslashes($N_Teacher);
$N_Email = addslashes($N_Email);
$N_date=date("d-m-y H:i:s");
$agent=$_SESSION['u_name'];
$division=$_POST['division'];
$divisionID=$_POST['divisionID'];
$position=$_POST['position'];
$positionID=$_POST['positionID'];
$employee=$_POST['employee'];
$wordcomm=$_POST['wordcomm'];
$N_Telefon=$_POST['N_Telefon'];
$hndl=fopen($_REQUEST["imgfile"],"r");
$isize=sizeof($_REQUEST["imgfile"]);
if (empty($hndl) ){
$hndl=fopen("temp.gif","r");
$imgdata="";
while(!feof($hndl)){ $imgdata.=fread($hndl,$isize); }
$imgdata=addslashes($imgdata);
$sql="INSERT INTO teachers2(N_Teacher,N_Email,position,N_date,agent,division,divisionID,positionID,wordcomm,employee, N_Telefon,imgtype,pic)VALUES ('$N_Teacher','$N_Email','$position','$N_date','$agent','$division','$divisionID','$positionID','$wordcomm','$employee','$N_Telefon','". $_REQUEST["imgtype"] ."','$imgdata')";
$result=mysql_query($sql);
if($result){
ECHO "<center><font color='088000' font face='Tahoma' size='2'><b> data inserted without any pictures </font></center></b>";
echo "<BR>";
$htmlfother=InCludePageHtml("template/fother.html");
eval("echo stripslashes(\"$htmlfother\");");
GoTO("Del_Edit.php");
}
else{
ECHO "<center><font color='ff0000' font face='Tahoma' size='2'><b>db error</font></center></b>";
echo "<BR>";
$htmlfother=InCludePageHtml("template/fother.html");
eval("echo stripslashes(\"$htmlfother\");");
GoTO("add.php");
}
}
else {
$hndl=fopen($_REQUEST["imgfile"],"r");
$isize=sizeof($_REQUEST["imgfile"]);
$imgdata="";
while(!feof($hndl)){ $imgdata.=fread($hndl,$isize); }
$imgdata=addslashes($imgdata);
$sql="INSERT INTO teachers2(N_Teacher,N_Email,position,N_date,agent,division,divisionID,positionID,wordcomm,employee, N_Telefon,imgtype,pic)VALUES ('$N_Teacher','$N_Email','$position','$N_date','$agent','$division','$divisionID','$positionID','$wordcomm','$employee','$N_Telefon','". $_REQUEST["imgtype"] ."','$imgdata')";
$result=mysql_query($sql);
if($result){
ECHO "<center><font color='088000' font face='Tahoma' size='2'><b> all data inserted </font></center></b>";
echo "<BR>";
$htmlfother=InCludePageHtml("template/fother.html");
eval("echo stripslashes(\"$htmlfother\");");
GoTO("Del_Edit.php");
}
else{
ECHO "<center><font color='ff0000' font face='Tahoma' size='2'><b>db issue -error </font></center></b>";
echo "<BR>";
$htmlfother=InCludePageHtml("template/fother.html");
eval("echo stripslashes(\"$htmlfother\");");
GoTO("add.php");
}
}
}
?>