So I've been trying to figure out how to store images in a mysql database, and as far as i can tell the images are stored but getting them out seems to be the problem.
when i try to go to the page on my webhost it says that
"Can not select the database: Access denied for user 'testimg'@'localhost' to database 'testImages'"
and when i goto show.php?id=1 on my local mamp install it gives me all kinds of weird symbols
ÿÀ�™Ì�ÿÄ�È���������������������������!1AQaq"2‘¡±BR#Ãbr‚’Ñ¢Â3CS$á²Òsƒ“%ðñc£Ã4â³T56Dtâ€E&Ód¤´ÄUu•7���!1AQaqð‘¡"2±ÃÑáñBRÂbr⢉#3ÿÚ���?�Ü/é -èÂ
i've checked everything in the code a million times and searched google and this forum for anything that can help me but i haven't been able to find something that has helped me understand what exactly is going on and why
heres the upload form
<form enctype="multipart/form-data" action="insert.php" method="post" name="changer">
<input name="MAX_FILE_SIZE" value="1500000" type="hidden">
<input name="image" accept="image/jpeg" type="file">
<input value="Submit" type="submit">
</form>
this is my insert.php that processes the image after its submitted
<?php
include './database.php';
$link = mysql_connect($host, $username, $password);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db ($database);
if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) {
$tmpName = $_FILES['image']['tmp_name'];
$fp = fopen($tmpName, 'r');
$data = fread($fp, filesize($tmpName));
$data = addslashes($data);
fclose($fp);
$query = "INSERT INTO tbl_images ";
$query .= "(image) VALUES ('$data')";
$results = mysql_query($query, $link);
print "Thank you, your file has been uploaded.";
}else{
print "No image selected/uploaded";
}
mysql_close($link);
?>
and heres the show.php that displays the image using the id
<?php
include './database.php';
@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'];
if(!isset($id) || empty($id)){
die("Please select your image!");
}else{
$query = mysql_query("SELECT image FROM tbl_images WHERE id='".$id."'");
$row = mysql_fetch_assoc($query);
$content = $row['image'];
header("Content-type: image/jpg");
echo $content;
}
?>
Loop column after 2 results
Hello All.Here is what I have:Client ID Company name Client ID Company nameI then need a script to echo 2 results per row then start a new row.I've tried many
Any help with my email script?
I have an email script, I have not tested it, although someone tested it for me and said it worked fine. I started to make modifications to the code after using the basic structure. This is my HTML
am I using this for loop correctly
Dear buddies!
Structure Question - One Table or One Table Per Record Set?
I have a web app (mySQL and PHP) which allows people to create an item with up to 200 records which I store in a single table. Any user subscribing to that item will be pulling up to 4 records from
help, header() is not working!
Hello, I have this code:<?php/** * @author samoi * @copyright 2009 */error_reporting(E_ALL & E_NOTICE);include ('func.php'); // this has the session_start() func!if
Using unserialize()
Hi there.I have some data in my database that is serialized.e.g. a:2:{i:0;s:9:"Test";i:1;s:4:"Another Test";}I'm unsure how to use unserialize to convert it into a string in the
Querying info from one table based on info in another
Hi, I am currently trying to make a part for my user driven website where one user can subscribe to another and whoever they have subscribed to is echoed back on there profile page. my users table
help me fix these syntax errors...
I keep getting multiple syntax errors on this script like this one:Parse error: syntax error, unexpected T_ELSE in .../scripts/php/loginform2.php on line 40when I change that line I get another on
Calculus Help (and by help I mean homework)
Hrmmm, I hate posting about math homework, partly because it's homework, and partly because I hate whenever I can't figure out math myself.Yes, I realize this is an extremely long post. Feel free to
Error when call dll from oracle
Hi all, please help me!