I have 2 samples of code. The first one works on the server and my harddrive. The second one only works on my harddrive. What would be the reason for that?
SAMPLE 1
<?php
$userid=$_POST['userid'];
$first=$_POST['first'];
$last=$_POST['last'];
$organ=$_POST['organ'];
$email=$_POST['email'];
$comments=$_POST['comments'];
@ $db=new mysqli('localhost','c4solutions','ftwash','ites');
if (mysqli_connect_errno())
{
echo 'Error: Could not connect to database.';
exit;
}
$query = "insert into itesuser(userid,first,last,organ,email,comments) values ('$userid' , '$first' , '$last' , '$organ' , '$email' , '$comments')";
$result = $db->query($query);
if ($result)
echo $db->affected_rows.' information inserted into database.';
$db->close();
?>
SAMPLE 2
<?php
$userid=$_POST['userid'];
$first=$_POST['first'];
$last=$_POST['last'];
$organ=$_POST['organ'];
$email=$_POST['email'];
$comments=$_POST['comments'];
echo "php is connecting";
exit;
}
@ $db=new mysqli('localhost', 'c4solutions', 'ftwash','ites');
if (mysqli_connect_errno())
{
echo 'Error: Could not connect to database.';
exit;
}
$query = "insert into itesuser values ('".$userid."','".$first."','".$last."','".$organ."','".$email."','".$comments."')";
$result = $db->query($query);
if ($result)
echo $db->affected_rows.' information inserted into database.';
$db->close();
?>
SAMPLE 1
<?php
$userid=$_POST['userid'];
$first=$_POST['first'];
$last=$_POST['last'];
$organ=$_POST['organ'];
$email=$_POST['email'];
$comments=$_POST['comments'];
@ $db=new mysqli('localhost','c4solutions','ftwash','ites');
if (mysqli_connect_errno())
{
echo 'Error: Could not connect to database.';
exit;
}
$query = "insert into itesuser(userid,first,last,organ,email,comments) values ('$userid' , '$first' , '$last' , '$organ' , '$email' , '$comments')";
$result = $db->query($query);
if ($result)
echo $db->affected_rows.' information inserted into database.';
$db->close();
?>
SAMPLE 2
<?php
$userid=$_POST['userid'];
$first=$_POST['first'];
$last=$_POST['last'];
$organ=$_POST['organ'];
$email=$_POST['email'];
$comments=$_POST['comments'];
echo "php is connecting";
exit;
}
@ $db=new mysqli('localhost', 'c4solutions', 'ftwash','ites');
if (mysqli_connect_errno())
{
echo 'Error: Could not connect to database.';
exit;
}
$query = "insert into itesuser values ('".$userid."','".$first."','".$last."','".$organ."','".$email."','".$comments."')";
$result = $db->query($query);
if ($result)
echo $db->affected_rows.' information inserted into database.';
$db->close();
?>