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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.