Jump to content

script works on local host but not on my uni server please help!!


joebudden

Recommended Posts

Iv written a script that allows a user to upload a file, delete, rename and download.

It works perfectly on my local host but have recently uploaded to my university server and certain parts are not working

here is the url:

http://php.cs.cse.dmu.ac.uk:6789/p03293858/cw/index.php

(if u want to try it)

user name = e1
password = pw1

main things that arent working:

1) on the view uploads  page next to download there should be a link to download the file with the filename in the box 

//code:

<a href='download.php?id=<?=$artefactId;?>'><?=$filename;?></a><br />

2) when rename is clicked the txt boxes usually have the filename and the extension in them but do not and thus the page does not rename the file

//code:

<a href='rename.php?id=<?=echo $artefactId;?>rename=<?=echo $filename;?>'>Rename</a><br />

3) the delete feature will not work althought it says file deleted wen i click delete ??

//code:

<a href='delete.php?del=<?=$artefactId;?>'>Delete</a><br />

Like i say the whole script works perfectly on local host and the server im uploading to is using the same versions of Apache and mysql.

ANY HELP would be very much appreciated


short_open_tag isnt enabled in php...

[code]<a href='download.php?id=<?=$artefactId;?>'><?=$filename;?>[/code]
is what the script is outputting...

Edit: you can try putting ini_set('short_open_tag', 'On'); at the top of the page, but I doubt it will work.

Instead you could just change all <?=var;?> to <?php echo var; ?>
Right,,,,,
                delete and download work but rename doesn't so there must be something wrong with my code as the page is getting the variables :

    http://php.cs.cse.dmu.ac.uk:6789/p03293858/cw/rename.php?id=3rename=rooney.gif

[code]

<?php

session_start();

require_once("cw1/error-handling.inc.php");
require("cw1/connect.php");
require("cw1/dbselect.php");

if (!isset($_SESSION['sessEmployee']))
{
include("index.php");
return; //a return here terminates the execution of this page.
}

if (isset($_POST["filename"]))
{
$id = $_POST["id"];

$strip = stripslashes($_POST["filename"]);
$rename = $strip . "." . $_POST["ext"] ;

$changename = "update artefact set filename='".$rename."' where artefactId='".$id."'";

mysql_query($changename,$con)or die('Error, cannot change name field');

if (mysql_query($changename,$con)or die('Error, query failed') == true)
{
echo "File Renamed";
echo "<p>" . '<a href="upload.php">' . "Click here to upload files" . "</a></p>";
echo "<p>" . '<a href="viewuploads.php">' . "Click here to view uploads" . "</a></p>";
echo "<p>" . '<a href="logout.php">' . "Logout!" . "</a></p>";
}
else
{
echo "An error occured: " . mysql_error();
}
mysql_close($con);
}
else
{

$filename = $_GET["rename"];
list($the_file_name, $extension) = explode('.', $filename);
echo "<p>What would you like to rename " . $_GET["rename"] . " to?</p>";
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" enctype="multipart/form-data">
<input name="filename" type="text" value="'.$the_file_name.'">
<input name="ext" type="text" value="'.$extension.'" readonly="true">
<input name="id" type="hidden" value="'.$_GET["id"].'">
<input name="oldname" type="hidden" value="'.$the_file_name.'">
<input name="oldext" type="hidden" value="'.$extension.'">
<input name="submit" type="submit" value="Rename this file now!">
</form>';
echo "<p>" . '<a href="upload.php">' . "Click here to upload files" . "</a></p>";
echo "<p>" . '<a href="viewuploads.php">' . "Click here to view uploads" . "</a></p>";
}
?>


[/code]


ANY IDEAS DUDES?????? it worked on local host

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.