Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I have a upload auto linked in a mysql table
    text
    copied!<p>I have a form that uploads a file with other information to a database and displays it in a chart. Right now the chart only displays the file name and doesen't link it. If the file was called test1.pdf, how would I make it so on the chart it still says chart1.pdf but links it to the directory that the file is on?</p> <p> <pre><code> if ('POST' === $_SERVER['REQUEST_METHOD']) { $con = mysql_connect("localhost","xxxx","xxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("jjlliinn_test", $con); $target = "clientdoc/"; $target = $target . basename( $_FILES['file']['name']); $date = $_POST['date']; $propertydescription = $_POST['propertydescription']; $transactiontype = $_POST['transactiontype']; $applicabledocument = ($_FILES['file']['name']); $received = $_POST['received']; $paid = $_POST['paid']; //Writes the to the server if(move_uploaded_file($_FILES['file']['tmp_name'], $target)) { //Tells you if its all ok echo ""; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } $sql = mysql_query("INSERT INTO `transactions` (`date`, `agentclient`, `propertydescription`, `transactiontype`, `applicabledocument`, `received`, `paid`) VALUES ('$date', '$agentclient', '$propertydescription', '$transactiontype', '$applicabledocument', '$received', '$paid')") or die(mysql_error()); $query = mysql_query($sql); if ($_SERVER['REQUEST_METHOD'] === 'POST') { echo "Succesfully added transaction. Updating table..."; echo "&lt;META HTTP-EQUIV=\"refresh\" CONTENT=\"48\"&gt;"; mysql_close($con); } } ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload