|
||||||
| PHP Tutorials PHP Tutorials |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
hi....... i am new to php...i like u r tutorial....its simple easy going.... i tried u r example of Tutorial: Storing Images in MySQL with PHP / Part II / Display your images , but i am getting this error....somthing like this Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\task\show_img.php:9) in C:\xampp\htdocs\task\show_img.php on line 30 and here is my code PHP Code:
Last edited by Jaan; 12-16-2008 at 09:39 AM.. Reason: Please use code tags when you're posting your codes! |
|
|||||
|
This error means you have already sent your headers somewhere. Do you have a space before or above <?php ? Is another script being executed first?
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog Post a job on our freelance section! Paste between computers/devices and Collaborate on Code!. |
|
|||
|
first of all thanks for u r .responce......... this is the whole code.......... Code:
<html>
<head>
<title>Untitled Document</title>
<!-- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> -->
</head>
<body>
<?php
$username = "root";
$password = "";
$host = "localhost";
$database = "test";
@mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());
@mysql_select_db($database) or die("Can not select the database: ".mysql_error());
//$id = $_GET['id'];
$id=4;
if(!isset($id) || empty($id)){
die("Please select your image!");
}else{
$query = mysql_query("SELECT * FROM images WHERE id='".$id."'");
$row = mysql_fetch_array($query);
$content = $row['img'];
header('Content-type: image/jpg');
echo $content;
}
?>
</body>
</html>
now i am not getting the error.....but the out put...is somthing like this........ �JFIF�������C� $.' ",#(7),01444'9=82<.342�C 2!!22222222222222222222222222222222222222222222222 222�4"������������ ����}�!1AQa"q2‘#BR$3br‚ ........and so ...on can u plzss...tell me what would b the problem.........and y is it happening so....! thanks in advance....... Last edited by Jaan; 12-17-2008 at 09:51 AM.. Reason: Please use code tags when you're posting your codes! |
|
|||||
|
As mentioned one page back in this thread, ABSOLUTELY NOTHING can be put before the "<?php" tag or after the "?>" for this script! It shall NOT have any HTML or HEAD or BODY, as it is NOT an Webpage, this is an image file you want to show. Tutorial: Storing Images in MySQL with PHP / Part II / Display your images |
|
|||||
|
you're right orjan.. You MUST NOT have anything after and before PHP tags!
__________________
![]() CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | Freelance Cheap & Professional Web Design | Need help? Send a PM |
|
|||||
|
Does it works now? and no problem ![]()
__________________
![]() CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | Freelance Cheap & Professional Web Design | Need help? Send a PM |
|
|||
|
hi......... jaan........ yess its working fine........ when i am trying to displaying only one image...........but when i am trying to display all the images of the tables then i am getting only one image that is .... the first image of the table here is the code Code:
<?php
$username = "root";
$password = "";
$host = "localhost";
$database = "test";
@mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());
@mysql_select_db($database) or die("Can not select the database: ".mysql_error());
$query = mysql_query("SELECT * FROM images")or die("Cannot exe----- select the database: ".mysql_error());
while($row = mysql_fetch_array($query)){
//echo $row['id'];
$content = $row['img'];
header('Content-type: image/jpg');
echo $content;
}
?>
say as........ echo $row['id'];---------->it is showing error Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\sun\show1.php:23) in C:\xampp\htdocs\sun\show1.php on line 28 JFIFC $.' ",#(7),01444'9=82<.342C 2!!22222222222222222222222222222222222222222222222 2224" and can you help me in display both images and other data from MSQL using PHP script. thanks in advance.............. Last edited by Jaan; 12-20-2008 at 07:51 AM.. Reason: Please use code tags when you're posting your codes! |
|
|||||
|
No. This script is made to fetch one picture at a time. that's why we use the id in the url. if you want to show several pictures, you would need to do this in ANOTHER script: similar to this: PHP Code:
the filename fetch.php is just something I made up now, and is the file where the picture fetching script is in. Conclusion, the script fetches ordered picture. if you want to fetch several pictures, you need to order each picture to be shown from your html or another phpscript |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Tutorial: Storing Images in MySQL with PHP | Jordan | PHP Tutorials | 23 | 06-02-2009 10:01 PM |
| Tutorial: PHP to MySQL | Jordan | PHP Tutorials | 9 | 09-05-2008 12:12 PM |
Algorithms and Data Structures
Programming Language Popularity
Code Collaboration
Podnet IRC Network
AmpHosted
Goal #1: 1,000 Blogs
Goal #2: 1,000 Wiki Pages
Goal #3: 300,000 Posts
Goal #4: 20,000 Threads
Done: 30%, 23%, 55%, 75%