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","ro ot","sreeni") ) {
$errmsg = "Cannot connect to database";
}
@mysql_select_d b("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),ema il varchar(30),cit y varchar(20),sta te varchar(20),zip int(7),country varchar(20),mon th varchar(20),dat e 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_f ile($_FILES['upload']['tmp_name'],"latest.img ");
$instr = fopen("latest.i mg","rb");
$image = addslashes(frea d($instr,filesi ze("latest.img" )));
if (strlen($instr) < 149000) {
mysql_query ("insert into pix13(name,emai l,city,state,zi p,country,month ,date,upload) values ('\"". $_POST[name] . "\",\"".$_P OST[email]. "\",\"".$_P OST[city]. "\",\"".$_P OST[state]. "\",\"".$_P OST[zip]. "\",\"".$_P OST[country]. "\",\"".$_P OST[month]. "\",\"".$_P OST[date]. "\",\"". $_POST[whatsit] . "\", \"". $image . "\")");
} else {
$errmsg = "Too large!";
}
}
$gotten = @mysql_query("s elect * from pix order by pid desc limit 1");
if ($row = @mysql_fetch_as soc($gotten)) {
$name = htmlspecialchar s($row[name]);
$email = htmlspecialchar s($row[email]);
$city = htmlspecialchar s($row[city]);
$state = htmlspecialchar s($row[state]);
$zip = htmlspecialchar s($row[zip]);
$country = htmlspecialchar s($row[country]);
$month = htmlspecialchar s($row[month]);
$date = htmlspecialchar s($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.i mg","rb");
$bytes = fread($instr,fi lesize("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