Could you show us the code for displaying the image too?
And I assume that funcReadWriteConn() function is your custom function to connect to the database?
In any case, this line of the code :
...you misplaced a space in the $the_staffid variable in strtoupper(trim($the_staf fid)).Code:$query="SELECT rtype FROM pixtable WHERE ucase(trim(rstaffid))='".strtoupper(trim($the_staf fid))."'";
Btw, if you're copy-pasting the code, please put 'em between the [PHP] tags, thanks...
Notice: Undefined index: image_id in C:\wamp\www\Untitled-9.php on line 20
Please select your image!
it says error on my id why is it sir?
sir help me cant view my upload image thi this my upload.php
and my show.phpCode:<body>
<?php
// Create MySQL login values and
// set them to your login information.
$username = "dots";
$password = "dots";
$host = "localhost";
$database = "doctrack";
// Make the connect to MySQL or die
// and display an error.
$link = mysql_connect($host, $username, $password);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
// Select your database
mysql_select_db ($database);
// Make sure the user actually
// selected and uploaded a file
if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) {
// Temporary file name stored on the server
$tmpName = $_FILES['image']['tmp_name'];
// Read the file
$fp = fopen($tmpName, 'r');
$data = fread($fp, filesize($tmpName));
$data = addslashes($data);
fclose($fp);
// Create the query and insert
// into our database.
$query = "INSERT INTO testblob ";
$query .= "(image) VALUES ('$data')";
$results = mysql_query($query, $link);
// Print results
print "Thank you, your file has been uploaded.";
}
else {
print "No image selected/uploaded";
}
// Close our MySQL Link
mysql_close($link);
?>
</body>
</html>
THANKS so MUchCode:<body>
<?php
$username = "";
$password = "";
$host = "localhost";
$database = "";
@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());
$image_id = $_GET['image_id'];
if(!isset($id) || empty($id)){
die("Please select your image!");
}else{
$query = mysql_query("SELECT * FROM testblob WHERE image_id='".$image_id."'");
$row = mysql_fetch_array($query);
$content = $row['image'];
header('Content-type: image/jpg');
echo $content;
}
?>
</body>
</html>
Last edited by Jaan; 01-19-2010 at 03:51 PM. Reason: Removed database info and added tags!
First of all, your conditional is using the wrong variable.
It should be :Code:$image_id = $_GET['image_id'];
if(!isset($id) || empty($id)) {
die("Please select your image!");
}
And then, you have to pay attention to the data type of the image_id field (or column) on your database.Code:$image_id = $_GET['image_id'];
if(!isset($image_id) || empty($image_id)) {
die("Please select your image!");
}
If it's a string, you can use the current code on your show.php to show it.
If it's an integer, it should be changed from
toCode:$query = mysql_query("SELECT * FROM testblob WHERE image_id='".$image_id."'");
You also need to remove the <html> and <body> tags from your show.php.Code:$query = mysql_query("SELECT * FROM testblob WHERE image_id=$image_id");
Code:$query="SELECT staff_id,type,size,pix FROM picturetable WHERE ";
$query.=" ucase(trim(staff_id))='".strtoupper(trim($the_staff_id))."'";
$rst=mysql_query($query,$dbcon);
if($rst) $row_no=mysql_num_rows($rst);
if($row_no>0)
{
$row=mysql_fetch_assoc($rst);
header("Content-type: image/jpeg");
print $row['pix'];
}
Last edited by Jaan; 01-19-2010 at 03:52 PM. Reason: Please use code tags when you are posting your codes!
Thanks, Jaan...that helps a lot. =)
@tayolad
Hmm...yeah, I think I can see where it might get wrong, but this is just a wild guess.
Do you use Windows as your server's OS?
If that's the case, you should change this line :
intoCode:$fp = fopen($tmpName, 'r');
For Windows-based systems, a 'b' should be added when using fopen() to open a binary file.Code:$fp = fopen($tmpName, 'rb');
I'm also a bit confused by this line :
Why didn't you just write it like this?Code:$query.=" ucase(trim(staff_id))='".strtoupper(trim($the_staff_id))."'";
Code:$query.="staff_id='".strtoupper(trim($the_staff_id))."'";
@Kinetics.. and you are right again those functions wont work if they are written like they were before.
why does when i call show.php inside the table it only displays the URL and not the image?![]()
when i call show.php alone its working fine but when i include it with some php it doest work at all. and it eds up not displaying anything at all except the URL of the page -.- i dont have any idea why its not working lol -.-
my code is something like this
thanks ^_^Code:<table width="800" border="0">
<tr>
<td><img src="http://forum.codecall.net/images/globalpos.jpg" width="241" height="53" /></td>
<td height="83" colspan="3"><?php include_once("buttons.php")?></td> // this is a javascript file
</tr>
<tr>
<td height="202"><?php include_once("ads.php")?></td> //this is a swf file
<td colspan="2"><?php include_once("text_index.php")?></td> // plain text file
</tr>
<tr><td><?php include_once("show.php")?></td> //this is where i have problem lol -.-
</tr>
</table>
Last edited by hardinera; 02-16-2010 at 06:27 PM.
That's because.. when you include that file.. (show.php is created as an image) and if you include this other code also.. then it messes up the code.Code:<td><?php include_once("show.php")?></td>
There can not be any output before header(); function but in your code.. there is so just change your code to:
and it should do the jobCode:<td><img src="show.php" alt="My Image" /></td>
-.- that code never entered my mind -.-
thanks for help jaan! really helped me a lot![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks