Jump to content

cle13

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

cle13's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi guys, I have a multiple file upload script that doesn't work properly. Its supposed to upload two files to two different directories but it only uploads one! Can someone help me please? The code is below thanx. [code]<?php //This is the directory where images will be saved $target1 = "publications1/"; $target2 = "publications2/"; $target1 = $target1 . basename( $_FILES['book_image1']['name']); $target2 = $target2 . basename( $_FILES['book_image2']['name']); //This gets all the other information from the form $title=$_POST['title']; $author=$_POST['author']; $DOP=$_POST['DOP']; $theme=$_POST['theme']; $abstract=$_POST['abstract']; $book_image1=($_FILES['book_image1']['name']); $book_image2=($_FILES['book_image2']['name']); $status=$_POST['status']; $category=$_POST['category']; $sub_category=$_POST['sub_category']; $link=$_POST['link']; // Connects to your Database mysql_connect("localhost", "cle", "pass") or die(mysql_error()); mysql_select_db("ipra") or die(mysql_error()); //Writes the information to the database mysql_query("INSERT INTO `publications` (title, author, DOP, theme, abstract, book_image1, book_image2, status, category, sub_category, link) VALUES ('$title', '$author', '$DOP', '$theme', '$abstract', '$book_image1', '$book_image2', '$status', '$category', '$sub_category', '$link')"); //Writes the photo to the server $task1=move_uploaded_file($_FILES['book_image1']['tmp_name'], $target1); $task2=move_uploaded_file($_FILES['book_image2']['tmp_name'], $target2); if($task1 && $task2) {//Tells you if its all ok echo "The Publication was Uploaded Successfully! <br> "; header("location:publist.php"); } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?>[/code] Thanx
  2. The code Im using is here. Uloading [code]function upload() { $upload="<br><center><strong>Upload Your Curriculum Vitae</strong> <hr color=gray><br> <form action=?process=upload  method=post enctype=multipart/form-data name=uploadform>       <input type=hidden name=MAX_FILE_SIZE value=2000000>       <input name=userfile type=file id=userfile><br><br>       <input name=upload type=submit value=Upload style='border:solid 1 gray;'> </form></center>"; return $upload; } [/code] viewing [code]function upload() { $upload="<br><center><strong>Upload Your Curriculum Vitae</strong> <hr color=gray><br> <form action=?process=upload  method=post enctype=multipart/form-data name=uploadform>       <input type=hidden name=MAX_FILE_SIZE value=2000000>       <input name=userfile type=file id=userfile><br><br>       <input name=upload type=submit value=Upload style='border:solid 1 gray;'> </form></center>"; return $upload; }[/code]
  3. Hello people. Could anyone help me with code for uploading documents to a database and viewing them after uploading them? I would like to include a part in my site where people upload cvs and they are able to view them after uploading. Thanx.
  4. Hey man, I've done exactly that but the details script doesnt display anything! Try to look at the code for me and tell me where my mistakes are. Thanx.
  5. <a href='page.php?school=".$school."'>View Info[/url] Thanx but I dont know what to put where. for example, in <a href='page.php?school=".$school."'>View Info[/url] I put <a href='viewscript.php? folder=" .$variable_to_be_sent."'>View Info[/url] Is that how I do it? or I got it wrong somewhere. Coz that returns an error. Thanx.
  6. Hi, I have a php script which searches for school name results in a database and displays them back as links to another php script which displays detailed information about the a particular school from the same table and database. Now the second php script is supposed to use a variable from the first php script. How can I send that variable. Please help. Below are the two scripts in question. search script. [color=brown][code]<html> <head> <title>School Search Results</title> </head> <body> <h3>School Search Results</h3> <?php //create short variable names $search1=$HTTP_POST_VARS['name']; $search2=$HTTP_POST_VARS['type']; $search3=$HTTP_POST_VARS['year']; $search3=trim($search3); if(!$search1)     {       echo 'You have not entered search details please go back and try again';       exit;       } $search1=addslashes($search1); $search2=addslashes($search2); $search3=addslashes($search3); $conn = mysql_connect('localhost','','pass'); if (!$conn)       {       echo 'Error: could not connect to database. Please try again later.';       exit;       } mysql_select_db('school'); $query = "select * from SCHOOL where sch_name like '%".$search1."%' or type like '%".$search2."%' or year like '%".$search3."%'"; $result = mysql_query($query) or die (mysql_error()."<br>Couldn't execute query: $query"); $num_results = mysql_num_rows($result); echo '<p>Search results found: '.$num_results.'</p>'; for ($i=0; $i < $num_results; $i++)     {     $row = mysql_fetch_array($result);     echo '<p>&nbsp;'.($i+1).'<a href=schselect.php>&nbsp;';     echo htmlspecialchars(stripslashes($row['sch_name']));     echo '</a><br>&nbsp;&nbsp;&nbsp;';     echo stripslashes($row['type']);     echo '<br>&nbsp;&nbsp;&nbsp;';     echo stripslashes($row['year']);     echo '</p>';     } ?> </body> </html>[/code][/color] view details script [color=brown][code]<? $sch_name=$_GET[sch_name]; mysql_connect("localhost", "","pass") or     die ("Could not connect to database"); mysql_select_db("school") or     die ("Could not select database");  // define the SQL command $query = "select * from school where sch_name = '$sch_name'"; // submit the query to the database $res=mysql_query($query); // make sure it worked! if (!$res) { echo mysql_error(); exit; } echo "<div align=\"center\">"; echo "<center>"; echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"8\" width=\"98%\">"; echo "<tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $res )) {   // Print out the contents of each row into a table   echo "<tr>";   echo "<td width=\"100%\" height=\"58\" colspan=\"2\"><strong><font size=\"7\">";   echo $row['sch_name'];   echo "</font></strong>";   echo "</td>";   echo "</tr>";   echo "<tr>";   echo " <td width=\"20%\"><font size=\"2\">YEAR OF ESTABLISHMENT</font>";   echo "<font size=\"3\"><br>";   echo $row['year'];   echo "</font>";   echo "<font size=\"2\">";   echo "<br>";   echo "<p><font size=\"2\">LOCATION</font><font size=\"4\"><br>";   echo "</font><font size=\"2\">";   echo $row['location'];   echo "<br>";   echo "<p><font size=\"2\">KIND</font><br>";   echo "<font size=\"2\">";   echo $row['kind'];   echo "<br><br>";   echo "<p><font size=\"3\">TYPE</font></p>";     echo "<p>";   echo $row['type'];   echo "</p>";   echo "<p>TEL:</p><p><font size=\"3\">";   echo $row['phone'];   echo "</font><br>";   echo "<p>POSTAL ADDRESS:</p><p><font size=\"3\">";   echo $row['address'];   echo "</font><br>";   echo "</td>";   echo "<td width=\"80%\"><p><strong><font size=\"4\">Headteacher's Message</font></strong></p><p>";   echo $row['ht_msg'];   echo "</p></font></td></tr>";   } echo "</table>"; echo "</center></div>"; echo "</table>" ?>[/code][/color] Thanx in advance.
×
×
  • 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.