note 33590 added to function.imagecreatefromstring

Ask a Question related to PHP Notes, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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. ...
    3. 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 --...
    4. 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...
    5. 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...
  3. #2

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139