Displaying Image Stored In Database
The user can browse and upload an image and the image is stored successfully in a seperate binary table (with userid and bin_data, filesize, filename, filetype). The photo is displayed properly when I point my broswer to a script called fileshow.php:
PHP Code:
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Problem Displaying Image From Database
I used the code below to pull out an image from a mysql database but nothing shows on the page and there was no error message to indicate any problem.What could be wrong.The image is actually in the database with all the details: <?php if(isset($_GET[loginid])) { $con=mysql_connect("localhost","name","pass"); if(!$con) { die('Could not connect to database:'.mysql_error()); } mysql_select_db("datab",$con); $id = $_GET[loginid]; $query = "SELECT name, type, size, content " . "FROM image WHERE id= '$id'"; $result = mysql_query($query) or die('Error, query failed'); $file=mysql_fetch_array($result); $name=$file['name']; $type=$file['type']; $content=$file['content']; header('Content-length: '.strlen($content)); header("Content-type: $type"); header("Content-Disposition: inline; filename=$name"); echo $content; } mysql_close($con) ?>
Determine Image Information On Image Stored In MySQL BLOB
I store images in my DB as BLOB. When I want to place them in an html table, I want to determine the width of the image in order to asign the correct width to the column inside table. For JPEGs this is working fine, this is my code: $image = @imagecreatefromstring($r["foto"]); return @imagesx($image); where $r["foto"] is the field selected from the db which contains the image. For GIFs however, its getting really on my nerves !! I know imagecreatefromstring is not supported in gd2 and I tried several thinks. None of them worked ! : - $temp = tmpfile(); list($width, $height, $type, $attr) = getimagesize($temp); echo $attr; gives me :Warning: getimagesize: Unable to open 'Resource id #6' for reading - $handle = fopen("/tmp/tmp.dat", "w+"); fwrite($handle, $r["foto"]); list($width, $height, $type, $attr) = getimagesize($handle); echo $attr; gives me : Warning: getimagesize: Unable to open 'Resource id #6' for reading - Doing this with imagecreatefromgif($temp); wont work either ! Can somebody help me out please? by telling me what I'm doing wrong or what I should do.
Templates Stored In Database
I have a form where a user can enter different feild, for simplicities sake, say a 'To:', 'From' and 'Message' feild. The can select a 'template' from the databse, each one has different layouts, images etc, and is sotred as HTML code in the mySql. My question is how do I insert the vairables into the correct places in the template? I realise if it was hard-coded I could use something like: echo "To:". $to. "<br><br>". $message. "<br><br>From:". $from; etc, although this is simplified alot and the ones int databse contain images, tables, css etc. I don't really want to hardcode them using IF statements as I want it to be easy to add new 'templates'.
Form Data Not Stored In DataBase
I was trying setting up these scripts following instructions in a book from 2003, so I thought maybe some of the code might be outdated. Basically this is what Is supposed to happen: 1.- Display a form, enter details into fields and click submit. 2.- After having clicked on submit you're redirected to another page that will display the entered values and store them in the MySQL DB specified. Now what happens is that no errors are displayed after clicking on the submit button in the form, but neither are the entered values. In PHPMyAdmin I can see that the Db is still empty. I created a total of 3 files that reside in the same folder: The form, that when clicking on submit is redirected to the next file: Code:
Database-stored Webpage-content?
more and more pages seem to be extracted entirely from a database. Not only dynamic information, like search-engines, but also (semi-)static content, (just text/information) Does anybody know a good tutorial on: how to set up the needed effective structure for these database-driven websites?
Photos Stored In Database Or As Files
I have a question to you. I would like to create photo gallery. I wonder if I should store photos (uploaded by users) in database $data = file_get_contents($_FILES['photo']['tmp_name']); $data = mysql_real_escape_string($data); // Preparing data to be used in MySQL query mysql_query("INSERT INTO {$table} SET ext='$ext', title='$title', data='$data'"); $msg = 'Success: image uploaded' or I should store uploaded photo files as files in the server folder? Few years ago in my previous work I worked in MS Access application, and in my opinion storing photos in this database are not so good, becuase uploaded photo files stored in MS Access application, enlarged the database a few times. That`s why storing such files in database is not so relevant and the better way was to saved these files in the specified folder. What about Mysql?
Viewing Images Stored In A Database
I've written this script which is supposed to take an image uploaded by a user and put it in to a database, then at a later date be able to extract the image from the database and display the image to the user. The problem is that whenever I try to display the image, all I get is an error message that the image contains errors. Can anyone tell me where or why these errors might be coming up? Here is my script (I'm pretty sure it's all there):
Form Data Not Stored In Database ?
This is the code for a Returns form where I am trying to implement these validations: 1. Check if fields aint empty 2. Check if SESSION_username = username from Customer table and get customer ID use that Customer ID to look up Orders table and find if the ORDER NO. that has been entered is = an order no. in the Orders table i.e. see if the oder no. entered was actually an order placed by the user b4 * Customer table has cust id and username. Order table has only cust ID. returns table will store username from Session so that it can display each user's individual returns. Code:
Image Upload Problem - New Image Not Displaying
I have a consistent problem that needs knocking on the head. I have an image upload script that uploads an image and replaces the old image. The image that is displayed is sometimes that old image and the page must be manually refreshed to get the new one. I need the new image to be displayed with out have to manually refresh the page. So far I have identified the following: • Ive been testing in ie and firefox – the problem only happens in firefox. • If the upload script is activated more than once it works as desired – but not the first time. I need it to work the first time. • I have set the page to automatically refresh. – this works in ie, but firefox still needs a manual refresh. • I’ve included the following which makes no difference: • header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); • header("Cache-Control: no-cache"); • header("Pragma: no-cache");
Using Variable Names Stored In Database Fields.
I'm working on a project where I need to store a CGI query in a database field. The query contains variables which will be substitued at runtime (e.g., today's date, key to select upon, etc), and may be pointed to different URLs depending upon the table key. The variable substitution works fine when hardcoding into the script, e.g.: $var1='data1' $var2='data2' $a="http://www.webserver.com/query.cgi?a=$var1&b=$var2"; $fd=fopen($a,"r"); ... However, the substitution fails when the query is pulled from a database record, e.g. //Only one record returned for testing purposes. // //location field (varchar) is: //"http://www.webserver.com/query.cgi?a=$var1&b=$var2" $var1='data1' $var2='data2' $dbconn=yadda yada; $dbquery=pg_query($dbconn,"select key,location from schema.table"); $row=pg_fetch_assoc($dbquery); $fd=fopen($row['location'],"r"); ... In this case, the variable substitution doesn't occur in the query (i.e., $var1 remains the string $var1, instead of changing into the value of say, ༿-23-2004'). I've tried different variations, and treating as a variable variable (with $$row['url'] and ${$row['url']}.
Limiting Number Of Records Stored In Database
Is there a way I can limit the number of records that are stored in a database? I am using a PHP guestbook script for personal use and only want to save say the last 100 messages.
Image Displaying
It looks as if you are creating the second image, but not saving it anywhere. This generates an image: imagejpeg($image_p, null, 100)." "; But what about $image? You do a copyresampled then destroy it. If you want to save the image, pass the second argument to imagejpeg.
Image Not Displaying?
My code doesn't seem to want to display the images in the location provided. I get renderings but floorplans are not working, any suggestions in what i am doing wrong? I checked permissions, i made sure the file exists, and thats what my code is suppose to be doing is if it exists than print the file, which i t does <?php print "<h1><img src='http://homes.pacificscene.com/images/browse/logos/" . $row[0] . ".jpg' alt='" . $row[1] . "' /></h1>"; print "<p>" . $row[6]; $linkresult = mysql_query("SELECT * from psh_commlinks where commID = '" . $row[0] . "'"); while ($linkrow = mysql_fetch_row($linkresult)) { print "<br />For more information about " . $linkrow[1]; print ", please visit:<br /><a href='" . $linkrow[2] . "'>" . $linkrow[2] . "</a>."; } print "</p>"; if (file_exists("http://homes.pacificscene.com/browse/features/" . $row[10])) { print "<p><a href='features/" . $row[10] . "' target='_blank'>View Features List</a></p>"; } if (file_exists("http://homes.pacificscene.com/browse/brochures/" . $row[8])) { print "<p><a href='brochures/" . $row[8] . "' target='_blank'>Download PDF brochure</a></p>"; } $query = "SELECT * from psh_siteplans WHERE communityID = '$ID' ORDER BY orderID"; $result = mysql_query($query); while ($row = mysql_fetch_row($result)) { print "<form action=" . $_SERVER['PHP_SELF'] . "?ID=" . $ID . "&siteID=" . $row[0] . " method='POST'>"; print "<table border='0' cellspacing='0' cellpadding='5'><tr>"; $window = "'http://homes.pacificscene.com/popup.php?type=renderings&ID=" . $row[0] . "','popUp','width=775,height=550'"; print "<td width='206' rowspan='8' valign='top'>"; print '<a href="javascript:;"><img border="0" src="http://homes.pacificscene.com/images/browse/renderings/' . $row[0] . '-TH.jpg" onclick="MM_openBrWindow(' . $window . ')" /></a>'; print "</td>"; print "<td width='135'><strong>Model</strong></td>"; print "<td>" . $row[1] . "</td></tr>"; print "<tr><td><strong>Appx Sq. Ft</strong>.</td>"; print "<td>" . $row[2] . "</td></tr>"; print "<tr><td><strong>Stories</strong>.</td>"; print "<td>" . $row[3] . "</td></tr>"; print "<tr><td><strong>Bedrooms</strong>.</td>"; print "<td>" . $row[4] . "</td></tr>"; print "<tr><td><strong>Baths</strong>.</td>"; print "<td>" . $row[5] . "</td></tr>"; print "<tr><td><strong>Garage</strong>.</td>"; print "<td>" . $row[6] . "</td></tr>"; $window = "'http://homes.pacificscene.com/popup.php?type=floorplans&ID=" . $row[0] . "','popUp','width=825,height=625,scrollbars=yes'"; if (file_exists("http://homes.pacificscene.com/images/browse/floorplans/" . $row[0] . ".jpg")) { print '<tr><td><a href="javascript:;" onclick="MM_openBrWindow(' . $window . ')">Floorplan</td></a>'; print "<td> </td></tr>"; } $window = "'http://homes.pacificscene.com/popup.php?type=renderings&ID=" . $row[0] . "','popUp','width=775,height=550'"; if (file_exists("http://homes.pacificscene.com/images/browse/renderings/" . $row[0] . "-TH.jpg")) { print '<tr><td><a href="javascript:;" onclick="MM_openBrWindow(' . $window . ')">Enlarged Rendering </td></a>'; print "<td> </td></tr>"; } print "</table><br />"; } ?>
Displaying An Image From A MYSQL DB
Can someone point me in the right direction as to display an image in PHP that is being stored in MySQL? Basically I know how to store the image in MySQL, but getting it to display on a web page is what I am having trouble with.
Displaying An Image From Directory
I am new to php and having some troubles with something that should be relatively simple. I am trying to read an image file from a directory and display it in an html table. The catch is, the directory is not a set variable because it depends on the user who is logged in . this directory is called "$imagedirectory" below and is passed through a SESSION. for example $imagedirectory = "/htdocs/page/members/johnny_tracks/images/imagefile.jpg" the area of concern is highlighted below <img src="$imagedirectory"/> I have checked that the directory is correct AND that the file exists. I have no clue how to show the image, every I run it the output is either nothing or "/htdocs/page/members/username_tracks/images/imagefile.jpg". Code:
Displaying A Binary Image
I would like to know if anyone knows how I could go about sending an image to the browser that is binary. Here is what I am doing right now...but it's not working: header("Content-Type: image/jpeg"); header('Content-Disposition: inline; filename="image.jpg"'); $theImage = $thePage->GetAs("image.jpg", 350, 270, 60); imagejpeg($theImage); I have an ASP script that I am going off of to pull this together, and it uses "Response.BinaryWrite", is there an equivalent in PHP?
Displaying Image Stop The Script?
im using the gd function for displying an image, but after: imagepng($image); imagedestroy($image); seems the script stop without execute all the rest. why that?
Displaying From Database!
I'm trying to display products that are pulled form a database in a certain way using only DIV tags I would like the products to display across the page in rows of 4, however when i use div tags it is just putting one on each row.. whats the best way to display in a row of 4? here is an example script of what im using to experiment with: Code:
Displaying An Image Based On URL Origination-URL Redirect
I have several domains that use splash pages that point to my main site: i.e. http://www.mysite.com/index.php. How do I replace an image, named "Logo.gif" on the main page "http://www.mysite.com/index.php" with the image named "logo.gif" from the URL splashpage, " http://www.mysite.com/SanDiego/" Both images are named logo.gif because the PHP script references logo.gif through the script in too many places...It is just easier to keep the name logo.gif Problem: If a user is on the San Diego page and clicks to the main page I want the user to feel that the site is all about SanDiego. If a user is on the Los Angeles page and clicks to the main page I want the user to feel that the site is all about Los Angeles. Hence the site and database will still be the same..I just want them to feel the experience is personalized for their city and this will be determined by changing the logo.gif. I am using an image named logo.gif that will display SanDiego for the San Diego page I am using an image named logo.gif that will display Los Angeles for the Los Angeles page I have seen some PHP code that uses php echo $picture I am not sure if this will work....
Displaying Content From Database
need some simple help with displaying content from a mySQL database using PHP. i want to know how to write a php script to display the latest entry in a table to an html page. and also how to adapt the script to display the latest x amount of entries.
Images In Database Vs. Image References In Database
i kept all of the uploaded images as files on the server, and created links to them in the database. I have been changing things around now (especially directories) and I am thinking of storing the images in the actual database. I read somewhere that this can be considered a bad practice, so i was wondering what the consensus here was. In my opinion, modifying all of the code to point to the correct directories everytime a page location changes seems like a pain in the a**.
Displaying Values From A Database From An Include
I've got a URL going to a template, e.g. www.mydomain.com/product.php?id=product_a where the template is product.php the tag after the ? refers to the product that should be displyed in the template, in this case product_a Inside the template (product.php) I've got:- <? $url = $id.".htm"; include("$url"); ?> This works fine so far. How ever I've also got an include inside the the template (product_a.php), called product_info.php, which is another php file that displays the product version and the platforms that it sits on. so in the the include (product_info.php) I have:- <?php $db = mysql_connect("localhost", "username", "password"); mysql_select_db("DATABASE",$db); $result = mysql_query("SELECT version FROM table1 WHERE id = id",$db); do { if ($myrow[0] != "") { echo "$myrow[0]n"; } } while ($myrow = mysql_fetch_array($result));?> however this displays all the version numbers within the table (for every product) I just want it to display the version number of the value of $id (www.mydomain.com/product.php?id=product_a)
Problem Displaying One Column Of One Row From A Database With PHP.
I have a small script with PHP that queries a MySQL database to pull out one row, where I want to be able to access each of the columns separately. I have tried several different variations and am able to get the entire row to print, but when I attempt to access the individual columns I get an error. Here is what I have so far: if (isset($_POST['memberNo'])): $link = mysql_connect('...','...','...'); mysql_select_db("..."); //Perform a test query $query = "SELECT * FROM users WHERE 'id' = " . $_POST['memberNo']; $result = mysql_query($query) or die(mysql_error()); $line = mysql_fetch_assoc($result); print $line; //Close connection mysql_close($link); The point of this code is to retrieve the user information to validate the login information sent in the previous form. I do not get an error with this code, but it also does not print anything. I know there is an entry in the database that matches data sent in the $_POST['memberNo'] variable, it is the only entry in the database. Changing the 'print $line;' to 'print $line["id"];' does not display anyting either.
Displaying Database And Getting Unwanted Results...
I want to display everyone in the database, but only if the 'level' field is larger than 0. Well, this works fine for most of the database... but if the last entry in the database is 0, then it prints it anyways. Is there anyway around this? I tried adding an if statement before the last bit where I echo out the table rows, but it was killing the entire table, or still showing the same results. Code:
Displaying Results From Database In A Particular Format
How do I display results from a database in a particular format. For example the following text in this format including the lines in stored in the database: Quote“Hello, Welcome to the news for 11/06/07. Thanks” When I echo the results using the usual, <? echo $row_news[‘news’]; ?> it doesn’t echo the information in the database in the format it is stored for example it will display like this. Quote“Hello, Welcome to the news for 11/06/07. Thanks” How do I get it to display in the format it in displayed in the database?
Displaying Database Information In Columns
I have a database with products in and I want iT to automatically show every product on the page. Now I am able to do this easy enough but what I am struggling to do is that I want the products to be displayed in 3 columns. I can get them to display one under the other easy enough but I want them to be in rows with 3 columns instead.
Displaying Multiple Items From Database
what i have is a page that has four sections. what i want to have is when the page opens, in that page i want the lastest two items for each section from a database to be displayed. the items to be displayed are an image, a title and a description. but i also want the description to be shortend to say about 25-30 words or about 100 chars, if thats easier? so in the end i have 4 sections, each showing the lastest two items for each section. would the best way to do this be to have a seperate table in the database for each of the sections? or would i be able to do it from one table? would i have to creat a query for each of the sections? e.g: SELECT * FROM table WHERE section=section
Security Code Image In PHPNuke Login Isnt Displaying
i installed the PHP Nuke in a remote web space bought from prackhost.Problem is that iam not able to get the security code to login to the site as admin or normal user. All the remaining images like links and logo are comming except that security code. Iam not able to do any furthur action.
Displaying A List Of Categories From A Database In A Select Box
Could someone please tell me why this outputs nothing <select name=categories> <? $cat_array = get_categories(); foreach($cat_array as $this_cat) { echo "<option value=""; echo $this_cat["category_id"]; echo """; echo ">"; echo $this_cat["category_name"]; echo " "; } ?> </select> ========================================================== function get_categories() { //get the list of categories from the database $conn = mysql_pconnect("localhost", "user", "pwd"); $query = "select * from categories"; $result = mysql_query($query); if(!$result) return false; $num_cats = mysql_num_rows($result); if($num_cats == 0) return false; $result = db_result_to_array($result); return $result; } //A function that returns a query to the database as an array function db_result_to_array($result) { $res_array = array(); for($count=0; $row=@mysql_fetch_array($result); $count++) $res_array[$count] = $row; return $res_array; }
Reading And Displaying A Date From A MySql Database
I've just started using php, and although I am very impressed by it, there are some things with which I am confounded! What I'm trying to do is read in a Date from a mySql database and then display it on screen (the Date is in the usual yyyy-mm-dd format). If I use SQL on phpadmin SELECT Date FROM details WHERE details.Name = "Paul Lee" LIMIT 0 , 30 The result comes up 2005-01-01, so this seems to work. But if I use the following: $db = mysqli_connect("localhost","root",""); @mysqli_select_db($db, "personnel") or die ( "Unable to select database" ); $query = 'SELECT Date FROM details WHERE details.Name = "Paul Lee" LIMIT 0, 30' $result=mysqli_query($db, $query); echo "<br>"; echo $result; mysqli_close($db); I get "Object id #2" displayed on screen. I have tried to use the explode function to separate the months, year and day using the "-" as a delimeter, but this doesn't work, and I can't seem to get the other php date/time functions to work either.
Displaying Information From A Database In A Text Field,
I am trying to create an admin page, but before I get anywhere near that, I need to understand how to get data froma database to show up in appropriate form fields *text, textarea, etc...* I am able to get content from my database to show up in my template, now I want to create a page that allows a user to click on a link for which they want to edit the information (name, and bio) So I want that page to show up with a simple form, a text field displaying the name, and a textarea displaying the bio information, so that they can modify it and save it to the database. how do you get the information to show up in the form fields? Code:
Previous And Next Links And Displaying Database Information
I would like to display a listing of files on a web page as follows: If there is only one file: display the section name and then display the current file. If there is more than one file (for the first page): display the section name, the current file and a few archive files. If there is more than a page full (for each additional page): display the section name, and the next set of archive files. This is the code I have been working with (it's a bit ugly, suggestions are welcome). For some reason the second page of listings skips the first item. 1st page lists items 0 through 4, second page skips item 5 and starts displaying item 6. function display_table($sec_id, $num_item){ GLOBAL $link; $updir = "../uploads/"; //maybe this should be a GLOBAL variable??? if (isset($_GET['start'])){$start = $_GET['start'];}else{$start = 0;} //GLOBAL $start; //query DB $query_total = "SELECT file_id FROM files WHERE file_section_id =" . $sec_id ; $query = "SELECT file_id, file_meeting_date, file_meeting_time, file_title, file_modified, file_section_id, sec_name, sec_id, sec_disp_archive FROM files f, section s WHERE f.file_section_id =" . $sec_id . " AND f.file_section_id = s.sec_id ORDER BY file_modified DESC LIMIT " . $start . "," . $num_item; $result = mysqli_query( $link, $query ) or die(mysqli_error($link)); $result_total = mysqli_query( $link, $query_total ) or die(mysqli_error($link)); $num_rows = mysqli_num_rows($result_total); //print $query; //create hyperlinks and display table //display current file /* print "START: " . $start . "NUMBER: " .$num_item . " ROWS: " . $num_rows;*/ /*$obj = mysqli_fetch_object($result);*/ if ($num_rows > 1){ //Display current and archive files //only display current table if start is not set (not on page 1) $obj = mysqli_fetch_object($result);//Call DB $content = "<div id ='MainContent'><p><b>" . $obj->sec_name . "</b></p><table width=ï`%' border=Ƈ'>"; if (!isset($_GET['start'])||$_GET['start']==0){ //for 1st item display file info $content.= "<tr><td colspan=Ɖ' align='center'>Current</td></tr>"; $content.= "<tr bgcolor='#CCCCCC'><td width=ཝ%'>Meeting Date</td><td width=ཝ%'>Meeting Time</td><td width=ཞ%'>File</td></tr>"; $content .= "<tr><td>" . date("F jS, Y",strtotime($obj->file_meeting_date)) . "</td><td>" . date("g:i A",strtotime($obj->file_meeting_time)) . "</td><td><a href='" . $updir . $obj->file_title . "'>" . "View Current File" . "</td><tr>"; $content .="</table>"; print "START: " . $start . "NUMBER: " .$num_item . " ROWS: " . $num_rows; //DEBUG
Displaying Block Of Text From MySQL Database
I would like to create a details.php page that displays all my products. I understand how to get the title, price, description etc from mySQL. But my problem is how do I get a list of data? For example say I want to display the features of a product in point form (list). What is the best way to do this? How do most common websites do this? Code:
Displaying Data From Mysql Database In A Drop Down List On Form.
I'm trying to do is display data from two different mysql tables from the same database in a drop down list on a html form. I have a fixtures table with the player1(userid), player2(userid), gameid, game, score1 and 2, what I want is to use the userid to get the players first name and surname from the members table (as it is a unique id), I need to do this bit before displaying it in the drop down. I think i need 2 querys to do this but when I have tried it it just echo's a blank value or the userid not the forname and surname that I want. I'm using the fetch_array function but just can't see where I'm going wrong, Code:
Image From Database
Can everyone tell me how can i display a image stored on the oracle database using PHP?
How To Get An Image From A Database ?
i'm using a liitle script to insert images in a mssql database. yes i know i'm not supposed to store images in a database, but after my images are only 3kb in size, i've decided to do it anyway. question: how would it be possible to get one of this images back on my disc? i've been looking through many posting in different forums. but all of them are hard to understand if you don't have any experiences using php. the code below is as far as i could get by now. but the downloaded file is only 318 bytes in size and can not be displayed. so obviously, my code is crep! but what am i doing wrong? 2. question: can a file be downloaded without prompting the user in advance? the whole application i'writing is for inhouse use only and therefor, the user should trust these files... $db = mssql_connect("xxxx","xxxx","xxxx") or die("Can't connect to mssql server."); mssql_select_db("xxxx", $db) or die("Can't select database."); $get_image = "SELECT IMAGE_BIN,IMAGE_NAME FROM dbo.IMAGE WHERE ID_GCP =51 And ID_LEVEL_IMG=2"; $get_image_result = mssql_query($get_image) or die("Couldn't get image."); $binary = @mssql_result($get_image_result,0,"IMAGE_BIN"); $name = @mssql_result($get_image_result,0,"IMAGE_NAME"); header("Content-Disposition: attachment; filename=$name"); header("content-Type: attachment; image/jpeg");
URL Of Image Into Database
I can upload an image and copy it into a folder and i'm trying to put the url into a database. The first half of the url goes in but the filename goes in still as as variable, eg C:/Program Files/xampp/htdocs/epeople/uploads/$uploadFilename Code:
Image Into A Database
I'm trying to put an image into the same record as the logged-on username and other data by using 'update' but, from what i read i have to use the 'upload' command. Can you tell me if i can upload an image into the same record as the logged-on username, and if so, how? Code:
Uploading Image To Database
I'm using this code to upload an image from a form to a mysql database. It works fine except if I leave the input='file' blank, it removes the existing image if there is one. I want to leave an existing image as is unless a new one is uploaded. I've tried all sorts of things in place of $image=0; and it always removes the existing image from the database. if(isset($_POST['submit'])) { if(!empty($_FILES['image'])) { $image=$_FILES['image']['name']; include "upload.inc.php"; $proc = new upload; $proc->set_max_size(180000); $proc->set_directory("/images/"); $proc->set_tmp_name($_FILES['image']['tmp_name']); $proc->set_file_size($_FILES['image']['size']); $proc->set_file_type($_FILES['image']['type']); $proc->set_file_name($_FILES['image']['name']); $proc->start_copy(); } else { $image=0; } $updatelink="Update table set image='$image' where ID='$ID'"; mysql_query($updatelink) or die("Could not update"); print "Image Updated"; } }
Insert A Image To The Database
I tried to insert a image to the database but whenever I do I get a error message called 'invalid hex code' any idea guys?
Updating A Image In A Database
I have a database that I plan to store some images in..and yes I've read that a number advise agaist this and with that all aside..the reason I'm doing it is it helps save what little space I have by using a free mysql server for the time being. Anyways..the problem is this..I can't seem to get the update to work. I have PHP 4.3.2, Apache 2.0.46 and MySql 4.0.13. Code:
Image Into Variable Or Database
i want to have an image in a variable so i can show it were ever i want the only catch is that i want the image to be called in the same page, i found this script but the problem is that you have to have an extra page to call the image. look at print_image.php is there a solution or is it just not possible without having two pages the script========================= by Elena Mitovska on February 18 2003, 02:10 Inserting images into database, field for storing image must be BLOB type: to choose image user: Upload.php <form name='MyForm' method=post enctype="multipart/form-data" action='Dofile.php'><input type=file name='userfile'><input type=submit value=Upload"> Dofile.php: $data = ""; $userfile = $HTTP_POST_FILES['userfile']['tmp_name']; //get file $fp = fopen($userfile, "rb"); while(!feof($fp)) { $data .= fread($fp, 1024); } fclose($fp); $data = addslashes($data); $data = addcslashes($data, ""); //insert image into database $Query = "INSERT INTO images VALUES (NULL,'$data')"; $res = $db->query($Query); OutputImages.php <img src="print_image.php?id=$id> print_image.php $MainSQL="SELECT image FROM images where id=$id; $res = $db->query($MainSQL); $data = $res[0][0]; header("Content-Type: image/jpeg "); header("Content-Transfer-Encoding: binary "); header("Content-length: " . strlen($data) . " "); //send file contents print($data);
Uploading An Image To A Database
I am just wondering if you can upload a picture the MYSqL database using PHP. I was thinking about it and the way i "think" it would be done is: You upload the image to a directory and at the same time, it creates a link and puts the link into the database pointing it towards the image on the server.
|