The below code can't take the images.plz tell that what is the problem in that code
[php]
<?php
// Connect to database
$errmsg = "";
if (! @mysql_connect("localhost","root","sreeni")) {
$errmsg = "Cannot connect to database";
}
@mysql_select_db("my_db1");
// First run ONLY - need to create table by uncommenting this
// Or with silent @ we can let it fail every sunsequent time ;-)
$q = <<<CREATE
create table pix (
pid int primary key not null auto_increment,
name varchar(20),email varchar(30),city varchar(20),state varchar(20),zip int(7),country varchar(20),month varchar(20),date int(3),imgdata longblob)
CREATE;
@mysql_query($q);
// Insert any new image into database
if ($_REQUEST[completed] == 1) {
// Need to add - check for large upload. Otherwise the code
// will just duplicate old file ;-)
// ALSO - note that latest.img must be public write and in a
// live appliaction should be in another (safe!) directory.
move_uploaded_file($_FILES['upload']['tmp_name'],"latest.img");
$instr = fopen("latest.img","rb");
$image = addslashes(fread($instr,filesize("latest.img")));
if (strlen($instr) < 149000) {
mysql_query ("insert into pix13(name,email,city,state,zip,country,month,date ,upload) values ('\"". $_POST[name] . "\",\"".$_POST[email]. "\",\"".$_POST[city]. "\",\"".$_POST[state]. "\",\"".$_POST[zip]. "\",\"".$_POST[country]. "\",\"".$_POST[month]. "\",\"".$_POST[date]. "\",\"". $_POST[whatsit] . "\", \"". $image . "\")");
} else {
$errmsg = "Too large!";
}
}
$gotten = @mysql_query("select * from pix order by pid desc limit 1");
if ($row = @mysql_fetch_assoc($gotten)) {
$name = htmlspecialchars($row[name]);
$email = htmlspecialchars($row[email]);
$city = htmlspecialchars($row[city]);
$state = htmlspecialchars($row[state]);
$zip = htmlspecialchars($row[zip]);
$country = htmlspecialchars($row[country]);
$month = htmlspecialchars($row[month]);
$date = htmlspecialchars($row[date]);
$bytes = $row[upload];
} else {
$errmsg = "There is no image in the database yet";
// Put up a picture of our training centre
$instr = fopen("latest.img","rb");
$bytes = fread($instr,filesize("latest.img"));
}
// If this is the image request, send out the image
if ($_POST[gim] == 1) {
header("Content-type: image/jpeg/jpg/zip");
print $bytes;
exit ();
}
?>[/php]
Before you continue: Please enclose any code within the proper code tags. See the Posting Guidelines on how to do that. - moderator