Ask a Question related to PHP Notes, Design and Development.
-
pmout@v95bis.com #1
note 33590 added to function.imagecreatefromstring
This work
getdata.php {Retrieve image from database}
<?php
global $iid,$result;
$conn = mysql_connect("localhost", "", "") OR DIE (mysql_error());
@mysql_select_db ("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 = @mysql_fetch_array ($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 -- [url]http://www.php.net/manual/en/function.imagecreatefromstring.php[/url]
Edit Note -- [url]http://master.php.net/manage/user-notes.php?action=edit+33590[/url]
Delete Note -- [url]http://master.php.net/manage/user-notes.php?action=delete+33590&report=yes[/url]
Reject Note -- [url]http://master.php.net/manage/user-notes.php?action=reject+33590&report=yes[/url]
pmout@v95bis.com Guest
-
note 33827 added to function.function-exists
This can be used to conditionally define a user function. In this sense, it can act as a sort of inline include_once(). For example, suppose you... -
note 33767 added to function.is-a
>>> USE OF CLASSES, OBJECTS and SESSIONS. <<< If you have an object, or an array that used in many pages, you need to serialize/unserialize it. ... -
note 33714 added to function.register-tick-function
please can anyone help me to discover if this function can be used to make a chat ---- Manual Page --... -
note 33626 added to function.imagecreatefromstring
@Adrian: What version of the GD lib do you use? Please note that GIF support is only available in versions < 1.6 due to patent issues. ---- Manual... -
note 33575 added to function.register-shutdown-function
If your script exceeds the maximum execution time, and terminates thusly: Fatal error: Maximum execution time of 20 seconds exceeded in - on line... -
alindeman@php.net #2
note 33590 deleted from function.imagecreatefromstring by alindeman
Note Submitter: [email]pmout@v95bis.com[/email]
----
This work
getdata.php {Retrieve image from database}
<?php
global $iid,$result;
$conn = mysql_connect("localhost", "", "") OR DIE (mysql_error());
@mysql_select_db ("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 = @mysql_fetch_array ($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>
alindeman@php.net Guest



Reply With Quote

