PHP NOTES 45 NOTE 33590 ADDED TO FUNCTION IMAGECREATEFROMSTRING
Date: 1 Jul 2003 13:47:04 -0000

Subject: note 33590 added to function.imagecreatefromstring
From: pmout@no-spam

This work
getdata.php {Retrieve image from database}
<?php global $iid,$result;
$conn = mysql_connect("localhost", "", "") OR DIE (mysql_error());
@no-spam ("database", $conn) OR DIE (mysql_error());
$sql = "SELECT * FROM product WHERE productID=";
$sql .= "'$iid'";
// 'MS103'";."$iid";
//$_GET["iid"];

$result = mysql_query ($sql, $conn) OR DIE (mysql_error());
if (mysql_num_rows ($result)>0) {
$row = @no-spam ($result);
$image_type = $row["filetype"];
$image = $row["bin_data"];
// Header ("Content-type: $image_type");
print $image;
}

?>

_____________________________________

to store
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php $dbc = MYSQL_CONNECT("localhost","","");
mysql_select_db("database",$dbc) or die(mysql_error());
$query = "select CategoryNameENG from categories";
$result=MYSQL_QUERY($query,$dbc) or die(mysql_error());
print "<form name='form1' method='post' action='storenew.php'>";
print "<select name='Teste' size='1'>";
while ($myrow = mysql_fetch_array($result)) {
$prodType = $myrow["CategoryNameENG"];
printf ("<option> $prodType </option>");

}
print ("</select>");
print ("<input type='submit' name='Submit' value='Submit'>");
print ("</form>");
?>
</body>
</html>

file for store and see imagies form database{storenew.php}

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>
<body>

<?php global $submit;

if ($submit) {
$dbc = MYSQL_CONNECT("localhost","","");
mysql_select_db("database",$dbc);

$data = addslashes(fread(fopen($form_data, "rb"), filesize($form_data)));


$query = "UPDATE product SET descricao='$form_description',
bin_data='$data',
filename='$form_data_name',
filesize='$form_data_size',
filetype='$form_data_type' WHERE ProductID = '".$id."' ";
$result=MYSQL_QUERY($query,$dbc); $result_quit = MYSQL_QUERY("quit",$dbc); $result_reload = MYSQL_QUERY("mysqladmin reload",$dbc);
MYSQL_CLOSE($dbc);

} //else {

// else show the form to submit new data:

$dbc = MYSQL_CONNECT("localhost","","");
mysql_select_db("database",$dbc);
$subquery = "select CategoryID from categories where CategoryNameENG='".$Teste."' ";


$subresult=MYSQL_QUERY($subquery,$dbc);
$tt=mysql_fetch_array($subresult);
$ss=$tt["CategoryID"];
$query = "Select * from product where Grupo='$ss'";

$result=MYSQL_QUERY($query,$dbc);

print ("<table border=1>");
while ($myrow = mysql_fetch_array($result)) {
$prodID = $myrow["ProductID"];
$bin_data = $myrow["bin_data"];
$filetype = $myrow["filetype"]; $prodShortDescENG = $myrow["ProductShortDescriptionENG"];



print ("<tr>"); print ("<td>$prodID</td>");
print ("<td>$prodShortDescENG</td>");
print ("<td><img src='getdata.php?iid=$prodID' alt='Campo 600159'></td>");
print ("<td>");
print ("<form method='post' action=$PHP_SELF enctype='multipart/form-data'>");
print ("<input type='file' name='form_data' size='40'>");
print ("</td>");

print ("<input type='hidden' name='form_description' value='$prodID'>");
print ("<INPUT TYPE='hidden' name='MAX_FILE_SIZE' value='1000000'>");
print ("<INPUT TYPE='hidden' name='Teste' value='$Teste'>");
print ("<input type='hidden' name='id' value='$prodID'>");

print ("<td>");
print ("<input type='submit' name='submit' value='submit'></form>");
print ("</td>");

print ("</tr>");

}
print ("</table>");
MYSQL_CLOSE($dbc);

//}

?>

</body>
</html>
----
Manual Page -- http://www.php.net/manual/en/function.imagecreatefromstring.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33590
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33590&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33590&report=yes


Date: 1 Jul 2003 14:05:26 -0000

Subject: note 33590 deleted from function.imagecreatefromstring by alindeman
From: alindeman@no-spam
Note Submitter: pmout@no-spam
----

This work
getdata.php {Retrieve image from database}
<?php global $iid,$result;
$conn = mysql_connect("localhost", "", "") OR DIE (mysql_error());
@no-spam ("database", $conn) OR DIE (mysql_error());
$sql = "SELECT * FROM product WHERE productID=";
$sql .= "'$iid'";
// 'MS103'";."$iid";
//$_GET["iid"];

$result = mysql_query ($sql, $conn) OR DIE (mysql_error());
if (mysql_num_rows ($result)>0) {
$row = @no-spam ($result);
$image_type = $row["filetype"];
$image = $row["bin_data"];
// Header ("Content-type: $image_type");
print $image;
}

?>

_____________________________________

to store
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php $dbc = MYSQL_CONNECT("localhost","","");
mysql_select_db("database",$dbc) or die(mysql_error());
$query = "select CategoryNameENG from categories";
$result=MYSQL_QUERY($query,$dbc) or die(mysql_error());
print "<form name='form1' method='post' action='storenew.php'>";
print "<select name='Teste' size='1'>";
while ($myrow = mysql_fetch_array($result)) {
$prodType = $myrow["CategoryNameENG"];
printf ("<option> $prodType </option>");

}
print ("</select>");
print ("<input type='submit' name='Submit' value='Submit'>");
print ("</form>");
?>
</body>
</html>

file for store and see imagies form database{storenew.php}

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>
<body>

<?php global $submit;

if ($submit) {
$dbc = MYSQL_CONNECT("localhost","","");
mysql_select_db("database",$dbc);

$data = addslashes(fread(fopen($form_data, "rb"), filesize($form_data)));


$query = "UPDATE product SET descricao='$form_description',
bin_data='$data',
filename='$form_data_name',
filesize='$form_data_size',
filetype='$form_data_type' WHERE ProductID = '".$id."' ";
$result=MYSQL_QUERY($query,$dbc); $result_quit = MYSQL_QUERY("quit",$dbc); $result_reload = MYSQL_QUERY("mysqladmin reload",$dbc);
MYSQL_CLOSE($dbc);

} //else {

// else show the form to submit new data:

$dbc = MYSQL_CONNECT("localhost","","");
mysql_select_db("database",$dbc);
$subquery = "select CategoryID from categories where CategoryNameENG='".$Teste."' ";


$subresult=MYSQL_QUERY($subquery,$dbc);
$tt=mysql_fetch_array($subresult);
$ss=$tt["CategoryID"];
$query = "Select * from product where Grupo='$ss'";

$result=MYSQL_QUERY($query,$dbc);

print ("<table border=1>");
while ($myrow = mysql_fetch_array($result)) {
$prodID = $myrow["ProductID"];
$bin_data = $myrow["bin_data"];
$filetype = $myrow["filetype"]; $prodShortDescENG = $myrow["ProductShortDescriptionENG"];



print ("<tr>"); print ("<td>$prodID</td>");
print ("<td>$prodShortDescENG</td>");
print ("<td><img src='getdata.php?iid=$prodID' alt='Campo 600159'></td>");
print ("<td>");
print ("<form method='post' action=$PHP_SELF enctype='multipart/form-data'>");
print ("<input type='file' name='form_data' size='40'>");
print ("</td>");

print ("<input type='hidden' name='form_description' value='$prodID'>");
print ("<INPUT TYPE='hidden' name='MAX_FILE_SIZE' value='1000000'>");
print ("<INPUT TYPE='hidden' name='Teste' value='$Teste'>");
print ("<input type='hidden' name='id' value='$prodID'>");

print ("<td>");
print ("<input type='submit' name='submit' value='submit'></form>");
print ("</td>");

print ("</tr>");

}
print ("</table>");
MYSQL_CLOSE($dbc);

//}

?>

</body>
</html>