Jump to content

[SOLVED] Code working on local host but not on server


hane

Recommended Posts

Hi I need some help please I got an image upload code that loads the image to the folder and stores the filename in a mysql database. Now it works 100% when I run the code locally with XAMPP but it doesnt update the record in mysql when I do it on my webserver.

 

Here is my action code:

 

<?php
$uploadDir = '../excaload/foto/';
$id=$_POST["id"];
if(isset($_POST['upload']))
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

$filePath = $uploadDir . $fileName;

$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error uploading file";
exit;
}

$con = mysql_connect("xxxxxxx","xxxxxxx","xxxxxx");
if (!$con)
  {
  die('Error connecting to database');
  }

mysql_select_db("xxxxx", $con);

if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}

mysql_query("UPDATE c_listing SET image ='" . "$fileName" . "' WHERE c_listing_id ='" . "$id" . "' ");

mysql_close($con);

echo "<img src='../excaload/foto/" . "$fileName" . "' alt='' width='300'/>";

}
?>

 

I just need someone else to look at the code because I've been going through it over and over and I'm missing it. All the rest of my insert and update statements on the website work. Thanks for having a look

change

mysql_query("UPDATE c_listing SET image ='" . "$fileName" . "' WHERE c_listing_id ='" . "$id" . "' ");

 

to

mysql_query("UPDATE c_listing SET image ='$fileName' WHERE c_listing_id ='$id' ");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.