Jump to content

CiszLaserna

Members
  • Posts

    5
  • Joined

  • Last visited

CiszLaserna's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. now my problem is i want the file to print in the result as a downloadable once i upload it usng the php file upload code.
  2. here is my upload_file.php <?php $allowedExts = array("jpg", "jpeg", "gif", "png"); $extension = end(explode(".", $_FILES["file"]["name"])); if ($_FILES["file"]["size"] < 20000) { if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br>"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br>"; echo "Type: " . $_FILES["file"]["type"] . "<br>"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); INSERT INTO reports (Stations,Title,Detail,Attach) VALUES('$_POST[stations]','$_POST[title]','$_POST[detail]','$_FILES[file]')"; } } } else { echo "Invalid file"; } ?> and here is my insert code for the result because a wanted to try if i can download the file i upload from the db itself <?php $con=mysql_connect("localhost","root",""); mysql_select_db("report"); $sql="INSERT INTO reports (Stations,Title,Detail,Attach) VALUES('$_POST[stations]','$_POST[title]','$_POST[detail]','$_FILES[file]')"; $sql_res = mysql_query($sql); header("Location: report.php?ok=1"); mysql_close($con); ?> form code html <form action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file"><br> <input type="submit" name="submit" value="Submit"> </form> im kinda new at php
  3. error is this Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\report\inbox.php on line 23
  4. Kinda new to php im using array to post the inbox of an email application but it seems i got an error this code here: <?php $hostname = "localhost"; $password = "password"; $database = "reports"; $username = "your_name"; //connection to the database $con = mysql_connect($hostname, $username, $password) or die("Connecting to MySQL failed"); //select a database to work with $selected = mysql_select_db("report", $con) or die("Could not select examples"); //execute the SQL query and return records $result = mysql_query("SELECT id, stations, title, detail from insert"); //fetch tha data from the database while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "ID:".$row{'Id'}. "Station:".$row{'Stations'}. "Title:".$row{'Title'}. "Detail:".$row{'Detail'}."<br>"; } //close the connection mysql_close($con); ?>
×
×
  • 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.