here's the code for retrieving the info in the pic..but the info in filedata only showing a set of strings.. -
-
<?php
-
$Link = mysqli_connect("localhost","root","tupi", "amyak_maleh");
-
if(mysqli_connect_errno()){
-
die("Mysql connection failed:".mysqli_connect_errno());
-
}
-
//$result1 = mysqli_query($Link, "SELECT filedata FROM filestorage ORDER BY form_no DESC LIMIT 1");
-
$result1 = mysqli_query($Link, "SELECT fileid, filename, filemime, filesize, created, filedata from filestorage");
-
if($result1)
-
{
-
if(mysqli_num_rows($result1) == 0){
-
echo "<p> there are no files in the database</p>";
-
}
-
else
-
{
-
echo "<table width = '100%'><tr>";
-
echo "<td><b>Name</b></td>";
-
echo "<td><b>Mime</b></td>";
-
echo "<td><b>Size(bytes)</b></td>";
-
echo "<td><b>Created</b></td>";
-
echo "<td><b>Filedata</b></td>";
-
-
while($row = mysqli_fetch_array($result1))
-
{
-
echo "<tr><td>".$row['filename']."</b></td>";
-
echo "<td>".$row['filemime']."</b></td>";
-
echo "<td>".$row['filesize']."</b></td>";
-
echo "<td>".$row['created']."</b></td>";
-
echo "<td><input type=\"image\" src=".$row['filedata']."/></b></td></tr>";
-
}
-
-
echo "</table>";
-
}
-
mysqli_free_result($result1);
-
}
-
else
-
{
-
echo "error! sql query failed";
-
echo "<pre>".$link->error."</pre>";
-
}
-
mysqli_close($Link);
-
-
-
?>
-
34 3114
as for any image in html, the src attribute specifies an URI to the image, not the image data itself.
how could i convert the strings into an image? what function should i use? to convert it?
thanks
you're not getting the point here. the image data belong into a separate file. - // html
-
<input type="image" src="path/to/image.php"/>
- // image.php
-
// ...
-
echo $row['filedata'];
if you closely examine Atli's code samples, you'll notice that he doesn't mix (binary) image data with html code.
i see.. it should be in a different page? ..so that it will be a valid code in src?
Here, save this as image.php -
header("Content-Type: image/jpeg");
-
-
$fileid = isset($_REQUEST['fileid']) ? $_REQUEST['fileid'] : false;
-
-
if($fileid)
-
{
-
$Link = mysqli_connect("localhost","root","tupi", "amyak_maleh");
-
if(mysqli_connect_errno())
-
{
-
die("Mysql connection failed:".mysqli_connect_errno());
-
}
-
-
$result = mysqli_query($Link, "SELECT filedata from filestorage where fileid={$fileid}");
-
-
if(is_resource($result))
-
{
-
$row = mysql_fetch_row($result);
-
echo $row['filedata'];
-
}
-
}
Then call: - <input type="image" src="image.php?fileid=YOUR_FILE_ID">
the result is Submit Query
why is that?
thanks
here's the code, and it appears only a this string: Submit Query -
<input type="image" src="image.php?fileid=<?Php $form_no; ?>" />
-
thanks
any other suggestions please?
thanks
where does "Submit Query" come from?
from the image.php.
thanks
whats this?when i click the submit query which is the one appeared insted of the image, it jumps to the image.php page then this is what appears: http://localhost/image.php?x=&y= @Dormilich
I mean, where dou you define such a string (which line of code causes that to appear)?
this is the code.. -
<form action="image.php" method="post">
-
-
<input type="image" src="image.php?form_no=<?Php echo $form_no; ?>" />
-
</form>
well, it does not explain where the string comes from, but it explains the strange submit.
obviously image.php is designed to be an image (representation), thus if you put it in your form's action it will be executed onsubmit (say, if you submit the form, you'll be returned an image (which is possible, but doesn't make sense)). solution: put the form handling script in the action attribute.
solution: put the form handling script in the action attribute.
what exactly i will put in the action attribute?
@Paul NIcolai Sunga
.....................
the script (resp. its file name) that processes the form data (may be the same as the current page)
what shall i do? it is still not working..
what is not working, the form or the image?
the image is not showing.. i tried to show it through the src itself and its okei but when the image that came from the database it is not showing,.. maybe the problem is in the database or in the code, but there is no sign error in the codes.
ok, then you have to make sure that the picture is saved correctly in the DB . there are some MySQL GUIs out, but unless you have a Mac I can’t recommend anything.
(If that’s possible I could try connecting to your DB and look myself)
i tried another code:
here's the code. it only displays a blank photo. i mean an x that is usually seen in a blank photo.. - <?php
-
-
$Link = mysqli_connect("localhost","root","tupi", "amyak_maleh");
-
if (!$Link)
-
{
-
trigger_error("Could not connect", E_USER_ERROR );
-
}
-
-
$result=mysqli_query($Link, "SELECT * FROM pix");
-
while($row=mysqli_fetch_assoc($result))
-
{
-
header("Content-type: image/jpeg");
-
echo "<img src=\"".$row['imgdata']."\" alt=\"".$row['title']."\" width=\"100\" length=\"100\"/>";
-
}
-
?>
-
I’ll give you a working example
HTML - <h4>
-
<a class="hook" id="mord">Mord an Bord</a>
-
</h4>
-
-
<p>11. Januar 2009, SachsenSonntag</p>
-
<div class="mitte">
-
<img src="img.php?iid=sas091" width="150" height="99" alt="Bild des Zeitungsartikels" title="Wohl bekomm’s! Ein Schlückchen zur Begrüßung der Passagiere" id="img_sas091"/>
-
</div>
img.php - <?php
-
require 'load.img.php';
-
$img = new ArticleIMG;
-
$img->display();
-
?>
methods - public function display()
-
{
-
if (!$this->requestImage())
-
{
-
exit;
-
}
-
-
if (!empty($this->DBimg['img_mime']) and !empty($this->DBimg['img_size']) and !empty($this->DBimg['img_data']))
-
{
-
header('Content-Type: ' . $this->DBimg['img_mime']);
-
header('Content-Length: ' . $this->DBimg['img_size']);
-
echo $this->DBimg['img_data'];
-
}
-
}
-
-
protected function requestImage()
-
{
-
$this->load();
-
-
if ($this->checkID($this->IID))
-
{
-
return $this->getImageData();
-
}
-
return false;
-
}
-
-
private function getImageData()
-
{
-
try
-
{
-
$PS = aDB::execute('img', array(':id' => $this->IID));
-
$this->DBimg = $PS->fetch(PDO::FETCH_ASSOC);
-
}
-
catch (PDOException $pdo)
-
{
-
ErrorLog::logException($pdo, __CLASS__, __METHOD__);
-
return false;
-
}
-
return true;
-
}
is this correct? -
-
$pic = $_FILES['Browse'];
-
-
$formid = mysqli_query($Link, "Select form_no from registration_form where last_insert_id() = form_no");
-
-
$formnum = mysqli_fetch_row($formid);
-
-
-
$querypic = mysqli_query($Link, "INSERT INTO pix(pid, imgdata) values('$formnum', '$pic')");
-
-
-
i am not certain with this code..
@Paul NIcolai Sunga
completely unnecessary (have a close look at what you want to do here… ;))
otherwise I can’t tell (too less info)
okei.. im trying a lot of codes that is why i am so confused.. the issue about the displaying picture from mysql is still unsolved..
yeah.. in atli's code there were files in the DB but when i tried to check my own, there was no files.. im going to start again.. hope i can do it.. i'll try to fix the codes.. the insert query maybe has an error..
here's now my code: -
-
<?php
-
error_reporting (E_ALL ^ E_NOTICE);
-
-
$pid = base64_decode($_GET['id']);
-
-
if(isset($_FILES['uploaded_file']))
-
{
-
if($_FILES['uploaded_file']['error'] == 0)
-
{$Link = mysqli_connect("localhost","root","tupi", "amyak_maleh");
-
if(mysqli_connect_errno()){
-
die("Mysql connection failed:".mysqli_connect_errno());
-
}
-
$name = mysqli_real_escape_string($Link, $_FILES['uploaded_file']['name']);
-
$data = mysqli_real_escape_string($Link, file_get_contents($_FILES ['uploaded_file']['tmp_name']));
-
-
$query = "INSERT INTO pix(pid, title, imgdata) values('$pid', '$name', '$data')";
-
-
$result = mysqli_query($Link, $query);
-
if($result)
-
{
-
$asd = "Succes! YOur file was successfully added!";
-
$alert = base64_encode($asd);
-
header("Location:registration.php?alert=$alert");
-
exit();
-
}
-
else
-
{
-
$asd = "Error! An error occurred while the file was being uploaded.
-
Error code:".$_FILES['uploaded_file']['error'];
-
$alert = base64_encode($asd);
-
header("Location:picul.php?alert=$alert");
-
exit();
-
}
-
mysqli_close($Link);
-
}
-
-
it is not inserting..
@Paul NIcolai Sunga
with this code the data has inserted.. but now im having a problem retrieving the photo..
i used this: -
<input name="image" type="image" src="asdf.php?imgid=<?Php echo $form_no; ?>" width="110" height="100"/>
-
asdf.php where the image come from. -
error_reporting (E_ALL ^ E_NOTICE);
-
-
$id = $_GET['imgid'];
-
-
$Link = mysqli_connect("localhost","root","***", "***");
-
if (!$Link)
-
{
-
trigger_error("Could not connect", E_USER_ERROR );
-
}
-
if(!isset($id) || empty($id)){
-
die("Please select your image!");
-
}else{
-
-
$query = mysqli_query($Link, "SELECT * FROM pix WHERE pid='$id' ");
-
$row = mysqli_fetch_assoc($query);
-
$content = $row['imgdata'];
-
-
header('Content-type: image/jpg');
-
echo $content;
-
-
}
-
and i tried this one: it still not showing: -
header('Content-Type: image/jpeg');
-
$id = $_GET['imgid'];
-
$id = isset($_REQUEST['imgid']) ? $_REQUEST['imgid'] : false;
-
-
if($id)
-
{
-
$Link = mysqli_connect("localhost","root","***", "***");
-
if(mysqli_connect_errno())
-
{
-
die("Mysql connection failed:".mysqli_connect_errno());
-
}
-
-
$result = mysqli_query($Link, "SELECT imgdata from pix where pid = '$id' ");
-
-
if(is_resource($result))
-
{
-
$row = mysql_fetch_row($result);
-
header('Content-Type: image/jpeg');
-
echo $row['imgdata'];
-
-
}
-
}
-
-
the photo is not showing..which do you think the good code should i use and enhance? so that i will not get confused...
thanks a lot...
help. which code should i use?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: larrybud2002 |
last post by:
I suspect many developers here have had to write a technical manual for
their software, and I'm wondering if you have any info as to industry
standards for formatting.
For example, should a...
|
by: Craig O'Shannessy |
last post by:
Hi all,
Just thought I'd mention that I really think this problem needs to be
fixed. I
I'm patching the 7.4RC1 JDBC drivers as we speak due to this optimiser
bug, and it's the third time...
|
by: nsh |
last post by:
mailing.database.mysql, comp.lang.php
subject: does "LOAD DATA" EVER work?!? I've tried EVERYTHING!
version info:
my isp is running my web page on a linux box with php ver. 4.4.1
according to...
|
by: angelicdevil |
last post by:
ok i have a folder made on the server and uploaded image files to it...the link to the image file or rather the path to the image is uploaded in the database in 'image_path' , now i want that the...
|
by: Paul NIcolai Sunga |
last post by:
are these codes are right?
these are what i use in retrieving the picture..
<?Php
error_reporting (E_ALL ^ E_NOTICE);
$Link = mysqli_connect("localhost","root","tupi",...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |