Im new to php and this forum and was hoping for a little help with my php code.
The page i have created is one that with a simple form, allows the user to upload an image to a folder and a corresponding url entry in the Image field of a record in my database.
This all works fine, but i have found that both instances of PRINT (that printed to screen the image name, type and size) doesnt work??? Neither does any echo i have in my code already or any others that i have added for testing, that even includes STATIC data???
Why arn't any echos or prints working???? Any ideas of help would be super
Thanks for Listening
Code: Select all
<?php require_once('Connections/woodside.php'); ?>
<?php error_reporting(E_ALL);
ini_set('display_errors', '1');
$file_dir = "C:/wamp/www/Woodside/Images/";
$link_dir = "./Images/";
$file_url = "http://localhost/woodside/Images/";
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
if (isset($_POST['submit']))
{
$image_name = $_FILES['image']['name'];
$image_size = $_FILES['image']['size'];
$image_type = $_FILES['image']['type'];
$uploadfile = $file_dir.basename($image_name);
echo"hello";
print_r($_FILES);
print "</pre>";
print "<center>Image path: $file_dir<br>\n";
print "<center>Image name: $image_name<br>\n";
print "<center>Image size: $image_size bytes<br>\n";
print "<center>Image type: $image_type<p><br>\n\n";
print "<img src=\"$file_url/$image_name\"><p>\n\n";
if (move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile))
{
echo "File is valid, and was successfully uploaded.\n";
$updateSQL = sprintf("UPDATE animal SET Image='%s' WHERE AnimalID=%u",
$link_dir.$image_name,
GetSQLValueString($_POST['panimal'], "int"));
mysql_select_db($database_woodside, $woodside);
$Result1 = mysql_query($updateSQL, $woodside) or die(mysql_error());
} else {
echo "Possible file upload attack!\n";
}
//Uncomment these lines if you are having problems
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
print "<center>Image path: $file_dir<br>\n";
print "<center>Image name: $image_name<br>\n";
print "<center>Image size: $image_size bytes<br>\n";
print "<center>Image type: $image_type<p><br>\n\n";
print "<img src=\"$file_url/$image_name\"><p>\n\n";
$updateGoTo = "latestTESTv2.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}}
$colname_animal = "-1";
if (isset($_GET['recordID'])) {
$colname_animal = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
}
mysql_select_db($database_woodside, $woodside);
$query_animal = sprintf("SELECT AnimalID, Image FROM animal WHERE AnimalID = %s", $colname_animal);
$animal = mysql_query($query_animal, $woodside) or die(mysql_error());
$row_animal = mysql_fetch_assoc($animal);
$totalRows_animal = mysql_num_rows($animal);
?><!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=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form name="form1" action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data"><br/>
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
<input type="file" accept=".jpg" size="20" name="image" title="Image Upload" /><br>
<input type="submit" name=submit value="Submit">
<input name="panimal" type="hidden" value="<?php echo $row_animal['AnimalID']; ?>" />
<input type="hidden" name="MM_update" value="form1">
</form>
</body>
</html>
<?php
mysql_free_result($animal);
?>