View Full Version : what's wrong with file uploading

02-26-2010, 08:52 AM
hi all,

can anyone tell me what's worng with this code?


include 'config.inc';
$id = $_GET['id'];

$wynik = mysql_query($zapytanie);

// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM pracownicy WHERE pracownik_id=$id") or die(mysql_error());

// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo $row['imie'];
echo $row['drugie_imie'];
echo $row['nazwisko'];
$skan_orzeczenie = $row['orzeczenie_skan'];
$dowod_osobisty = $row['dowod_osobisty'];
$paszport_pl = $row['paszport_pl'];
$paszport_inny = $row['paszport_inny'];
echo '<br /><br /><br />';

if (($skan_orzeczenie != NULL ) or ($dowod_osobisty != NULL ) or ($paszport_pl != NULL ) or ($paszport_inny != NULL )){
echo "sa skany<br />";
if ($paszport_pl != NULL ){echo 'paszport pl<br />'; };

if (!isset($_REQUEST["submit"])) {

<br /><br /><br /> Typ skanu ktory chcesz załadować: <br />
<form method="POST" action="scan_manager.php?id=<? echo $id ?>" enctype="multipart/form-data">
<select id="typ_skanu">
<? if ($dowod_osobisty == NULL ){echo '<option value="28">Dowód osobisty</option>'; }; ?>
<? if ($paszport_pl == NULL ){echo '<option value="29">Paszport PL</option>';}; ?>
<? if ($paszport_inny == NULL ){echo '<option value="30">Paszport inny</option>';}; ?>
<br />
Wybierz plik <input type="file" name="skan">
<input type="hidden" name="id" value="<? echo $id?>">
<input type="submit" name="submit" value="wgraj">
//-- save image to db --
} else {




$dbconn = @mysql_connect($dbserver,$dbuser,$dbpass) or exit("SERVER Unavailable");
@mysql_select_db($dbname,$conn) or exit("DB Unavailable");

$sql = "INSERT INTO skany VALUES (NULL,'". $_REQUEST["typ_skanu"] ."','". $imgdata ."')";
//$sql_upd_pracownik = "INSERT INTO pracownicy"
//$sql_upd_pracownik = "UPDATE"
@mysql_query($sql,$conn) or exit("QUERY FAILED!");



echo $_REQUEST["typ_skanu"];

02-26-2010, 09:30 AM


$imgdata=addslashes($imgdata); Are you storing the image into the DB? It'd be very easy and wise if you save you image inside a directory using move_uploaded_file() (http://php.net/move_uploaded_file) and store the path to image in DB.

02-26-2010, 09:34 AM
thanks for quick reply.

i would like to store it to filesystem, but i have to store as blob. this is because i have to base my code/application on existing db, so i have to follow another application structure.

do you have any ideas what is wrong?

i forgot to post config.inc

$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'admin';
$dbname = 'inplus';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname,$conn) or die(mysql_error());

02-26-2010, 10:05 AM
do you have any ideas what is wrong? Try removing all the error suppression operators (@) from your code.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum