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;
}
?>
Turning Data into URLs?
This may seem very basic to you, but I'm having a hard time figuring out how to do this since I don't even know what the proper term for it is:Background info:Animals Table - animalid, name, photo,
Progress bar for webpage
Hi,I want to implement a progress/waiting bar on my webpage - exactly the same thing that the Microsoft Update web page uses when your PC is being searched for available updates (the green bar that
PHP/PKI
I am trying to set up a web application that uses pki. does anyone have a good tutorial to set this up? I have a "dedicated server" to do all this on
Question about the upload of large files
Hi there,I have a question about the upload of large files, like videos (files generally above 20Mo).Is it better to use the FTP functions of php or the normal upload fonctions using additional
check if string contain only a-z/A-Z
Is where any way to check if string contains only a-z/A-Z, without writing an array with all possible letters and then looping it.Code: $available = array('a', 'b', 'c, 'd'); //write a-zfor
Struct/union and scope problem!
HI all , I have
MySQL noob question
hi guysI have a simple mysql table set up, along the lines of Col 1 - Col 2 - Date_last_updated--------------------------------Som - Some - 06/11/2009 23:23:23Bob - Bob - 06/11/2009 23:30:30and so
Target costs on Process orders not calculating
Hi All,
Simple Scraper... Weird Output
Okay, maybe I just need a Blue Monster and some sleep, but.... I'm scraping a ringtone site just so that I can download all of the ringtones and add them to my personal library.The website's code that
how do i display data on a page from mysql
1 - do i use this code at the top of each of my page i wish to only alow access if there as been a sessionCode: <?phpinclude_once 'Connect.php';if (!is_authed()) { die ('You are not