PHP - Read Mysql Database, Write Out Each Record To Txt File?
I have a MySQL database with each record of a person who has registered for an event, I am displaying the information on a web page for a user, but he wants to be able to print out all the records in alphabetical order by last name, first name later on so he will have a hard copy of each person who has registered at the table when they arrive. How can I write each record to a Txt file that he can print out later that will be formated with the record contents along with each fields definition (Ex. Last Name - Smith, First Name - John, etc)?
Similar TutorialsNot sure where to post this question. I have a MySQL database and add records with a PHP form to the tables. I have 2 fields (char) in one table. When the fields contain the character ' it wont write the record to the table! For example...if I enter. " John's house" it wont accept the record since ' appears in John's name! How do I work around this? Thanks I very new to php and all I am simply trying to do is read the contents of a text file and echo it out on the screen. I have tried many things to see what I am doing wrong but it just simply isnt working for me. I know the server I am using has php enabled as well because I have tried a simple echo and it works fine. This is the code I am currently using. <?php $file = fopen(file.txt", 'r'); $read = fread($file, '6') echo $read; ?> also, I have tried this. <?php $file = file_get_contents('file.txt'); echo $file; ?> I have a file.txt on the server I am using in the same directory as index.php, I feel like this should be working but I get no result! Alls I have in the text file is a statement that says "hello world". Hi, I want to read image file and write in to word document file using php. Actually i am developing shopping cart site. for that i have created barcode image. i need to take print outs. for example if i click print means same barcode should be generate 64 times in word document. how i do it? i have tried with COM. please check the following code <?php // starting word $word = new COM("word.application") or die("Unable to instantiate Word"); echo "Loaded Word, version {$word->Version}\n"; //bring it to front $word->Visible = 1; //open an empty document $word->Documents->Add(); //do some weird stuff for($i=1;$i<=64;$i++) { $word->Selection->InlineShapes->AddPicture("D:\Program Files\wamp\www\b.jpg ",false, True); } $word->Documents[1]->SaveAs("D:\Program Files\wamp\www\Uselesstest.doc"); //closing word $word->Quit(); //free the object $word = null; ?> It works fine in local. but it is not working in server (it says COM.class is missing). i have checked some forums they said it works with MS based operation system. i have checked with windows only. Please kindly any one help me asap the way for read and write image file in word document. can we do this any other way? we are reading and writing txt files using php the same can we do with image file (read and write in word document) ?? Thanks Prema Hi, I've been googling for a while now for an example of how to read, edit and write a configuration file. This part was easy to find... <?php $icon_settings = parse_ini_file("test.desktop"); print_r($icon_settings); ?> ...the above code works great, but how do I edit and write back a configuration file like this... Code: [Select] #!/usr/bin/env xdg-open [Desktop Entry] Version=1.0 Name=Firefox Web Browser Comment=Browse the World Wide Web GenericName=Web Browser Exec=firefox %u Terminal=false X-MultipleArgs=false Type=Application Icon=firefox # ... and so on back to the drive? Thanks. [/code] Hi //open the connection $conn = mysql_connect("localhost", "techhom1_test", "pro176"); //pick the database to use mysql_select_db("testDB", $conn); //create the sql statement $sql = "INSERT INTO master_name values ('', '$firstname')"; //execute if (mysql_query($sql,$conn)){ echo "Record Added!"; } else{ echo "Somethin went wrong"; } the code above is insert code and working with out any errors but when i am submitting text into data using method below it is sending echo back Somethin went wrong.I think i am confused with the write name of the user table database is ***_test my tables are duty_number master_name in this _test user i am trying to add first name in master_name field so here is the submit code Code: [Select] <FORM ACTION=insert.php METHOD=POST> <P>text to add:<br> <input type=text name=master_name size=30> <p><input type=submit name=submit value=Insert Record></p> </FORM> My table below in Data base [code]Field Type Null Default Comments name_id smallint(5) Yes NULL name_dateaddedn datetime Yes NULL name_datemodified datetime Yes NULL firstname varchar(75) Yes NULL lastname varchar(75) Yes NULL can someone please look at the code and find the error for me Thanks Hi On my xampp server's database I get the warning that my database is read-only when I try to insert something into a table. I think I may know what cause this, because I created an export/import app that exports/import important data to the database... How can I remove the read-only from the database, because I am scared that the same thing might happen to my server's database? And is there a mysql query that test if the database is read-only? Thanks in advance Here is what I am trying to accomplish: I have a students table with a studentID I also have a notes table and a sched table with studentID The sched table is working as planned where if the student is scheduled for more than one time he is displayed twice. However if there are multiple notes per student the student is display for each individual note where I would like only the most current note to be displayed Here is what the output is: 1- 10:30:00 - 10:50:00 student3 Three FST Teacher One Special1 One Writing Ratios 09/10 2- 10:30:00 - 10:50:00 student3 Three FST Teacher One Special1 One Needs to work on fractions and decimals 09/10 3- 13:00:00 - 14:00:00 student3 Three FST Teacher One Special1 One Writing Ratios 09/10 4- 13:00:00 - 14:00:00 student3 Three FST Teacher One Special1 One Needs to work on fractions and decimals 09/10 As you can see I have two notes and two schedule times for this student. what I want it to display is only line 1 & 3. which is the newest note in the system. Below is my code that I am using. Any help would be greatly appreciated. Code: [Select] <?php $result = mysql_query("SELECT * FROM students LEFT JOIN teachers ON students.teacherId = teachers.teacherId LEFT JOIN course ON students.courseId = course.courseId LEFT JOIN specialEd ON students.specialId = specialEd.specialId LEFT JOIN sched ON students.studentId = sched.studentId ORDER BY start "); echo "<table>"; while ($row = mysql_fetch_array($result)){ $id = "?id=" . $row['studentId']; echo "<tr>"; echo "<td>" . $row['start'] . " - " . $row['stop'] . "</td>"; echo "<td>" . "<a href='student.php$id'>" . $row['fName'] . " " . $row['lName'] . "</td>"; echo "<td>" . $row['courseName'] . "</td>"; echo "<td>" . $row['teachers_fName'] . " " . $row['teachers_lName'] . "</td>"; echo "<td>" . $row['special_fName'] . " " . $row['special_lName'] . "</td>"; echo "<td>" . $row['note'] . "</td>"; echo "<td>" . date("m/d", strtotime($row['started'])) . "</td>"; echo "</tr>"; } echo "</table>"; ?> I am trying to set up a item entry page form.png: Upon submission it shows unsuccessful even though I have checked the fields on mysql table and seem to be good am I missing something? Code: [Select] <form action="" method="post" enctype="multipart/form-data" name="Product_Entry"> <TABLE> <TR> <TD>Product ID</TD><TD><input name="SKU_ProductID" value="<?php if (isset($_post['SKU_ProductID'])) echo $_POST['SKU_ProductID']; ?>" type="text" size="11" maxlength="11" /></TD> </TR> <TR> <TD>Merchant SKU ID</TD><TD><input name="SKU_MerchSKUID" value="<?php if (isset($_post['SKU_MerchSKUID'])) echo $_POST['SKU_MerchSKUID']; ?>" type="text" size="18" maxlength="30" /></TD> </TR> <TR> <TD>Game Title</TD><TD><input name="Game_Title" value="<?php if (isset($_post['Game_Title'])) echo $_POST['Game_Title']; ?>" type="text" size="40" maxlength="40" /></TD> </TR> <TR> <TD>Platform</TD><TD><input name="Platform" value="<?php if (isset($_post['Platform'])) echo $_POST['Platform']; ?>" type="text" size="20" maxlength="20" /></TD> </TR> <TR> <TD>Genre</TD><TD><input name="Genre" value="<?php if (isset($_post['Genre'])) echo $_POST['Genre']; ?>" type="text" size="11" maxlength="11" /></TD> </TR> <TR> <TD>Weight</TD><TD><input name="Weight" value="<?php if (isset($_post['Weight'])) echo $_POST['Weight']; ?>" type="text" size="7" maxlength="7" /></TD> </TR> <TR> <TD>Supplier</TD><TD><input name="Supplier" Value="<?php if (isset($_post['Supplier'])) echo $_POST['Supplier']; ?>" type="text" size="25" maxlength="25" /></TD> </TR> <TR> <TD>Suppliers Price</TD><TD><input name="Supplier_Price" value="<?php if (isset($_post['Supplier_Price'])) echo $_POST['Supplier_Price']; ?>" type="text" size="10" maxlength="12" /></TD> </TR> <TR> <TD>Cashback</TD><TD><input name="Cashback" value="<?php if (isset($_post['Cashback'])) echo $_POST['Cashback']; ?>" type="text" size="6" maxlength="8" /></TD> </TR> <TR> <TD>Cashback Amount</TD><TD><input name="Cashback_Amount" value="<?php if (isset($_post['Cashback_Amount'])) echo $_POST['Cashback_Amount']; ?>" type="text" size="7" maxlength="11" /></TD> </TR> <TR> <TD><input type="hidden" name="submitted" value="true"/></TD><TD><input name="Submit" type="submit" value="Add_Product" /></TD> </TR></form></TABLE> <?php # Product Entry $page_title = 'Product Entry'; if (isset($_POST['Submit'])) { $errors = array(); if (empty($_POST['SKU_ProductID'])) { $errors[] = 'Please enter Product ID.'; } else { $sid = trim($_POST['SKU_ProductID']); } if (empty($_POST['SKU_MerchSKUID'])) { $errors[] = 'Please enter Merchant SKU.'; } else { $mid = trim($_POST['SKU_MerchSKUID']); } if (empty($_POST['Game_Title'])) { $errors[] = 'Please enter Game Title.'; } else { $gt = trim($_POST['Game_Title']); } if (empty($_POST['Platform'])) { $errors[] = 'Please enter Platform.'; } else { $pl = trim($_POST['Platform']); } if (empty($_POST['Genre'])) { $errors[] = 'Please enter Genre.'; } else { $ge = trim($_POST['Genre']); } if (empty($_POST['Weight'])) { $errors[] = 'Please enter Weight.'; } else { $we = trim($_POST['Weight']); } if (empty($_POST['Supplier'])) { $errors[] = 'Please enter Supplier.'; } else { $sup = trim($_POST['Supplier']); } if (empty($_POST['Supplier_Price'])) { $errors[] = 'Please enter Supplier Price.'; } else { $sp = trim($_POST['Supplier_Price']); } if (empty($_POST['Cashback'])) { $errors[] = 'Please enter Cashback %.'; } else { $cb = trim($_POST['Cashback']); } if (empty($_POST['Cashback_Amount'])) { $errors[] = 'Please enter Cashback Amount.'; } else { $cba = trim($_POST['Cashback_Amount']); } if (empty($errors)) { require_once ('connect.php'); [b]$q = "INSERT INTO `Products` (`SKU_ProductID`, `SKU_MerchSKUID`, `Game_Title`, `Platform`, `Genre`, `Weight`, `Supplier`, `Supplier_Price`, `Cashback`, `Cashback_Amount`) VALUES ('$sid', '$mid', '$gt', '$pl', '$ge', '$we', '$sup', '$sp', '$cb', '$cba')"; $r = @mysql_query ($dbc, $q); if ($r) { // If it ran OK. // Print a message: echo '<h1>Thank you!</h1> <p>Product Inserted!</p><p><br /></p>'; } else { // If it did not run OK. // Public message: echo '<h1>System Error</h1> <p class="error">You could not be registered due to a system error. We apologize for any inconvenience.</p>'; // Debugging message: echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>'; } // End of if ($r) IF. mysqli_close($dbc); // Close the database connection.[/b] // Include the footer and quit the script: include ('includes/footer.html'); exit(); } else { echo '<H1>Error!</H1> <p class="error">The Following error(s) occurred:<br />'; foreach ($errors as $msg) { echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p><p><br /></p>'; } } ?> If there is anything else needed let me know Hi, I am learning pdo php and mysql
I would like to know how to see whether a record has been read or not. I have a database messages with id, user_id, contact_id, login, msg, rrecord and msgtime.
The rrecord column has been set as 0 as default. When the client clicks the msg link, I would like it to update the rrecord to 1.
Thanks.
Hi Everyone, This is Tamilmani Mohan , i have an issue in to read the SP record set result by using SQLSRV queries. Sample PHP code is <?php $para = array(array($memberid,SQLSRV_PARAM_IN), array($start_date,SQLSRV_PARAM_IN), array($end_date,SQLSRV_PARAM_IN) ); $stmt = "{call MemberStatement(?, ?, ?)}"; if(!($result= sqlsrv_query($conn,$stmt ,$para))) { echo "Database Error"; die; } $arr_main = array();$totalpoints =0;while($row = sqlsrv_fetch_array($result)){ $arr_main[] = $row;$totalpoints = $totalpoints + $row['member_points']; }?>() When i execute the above i don't get any result. But if i run the above SP in management studio , i am able to see the result(8 rows are coming). I don't know the reason , why i don't get any result? Please any one give me the solution for this problem. Regards Tamilmani Mohan Hello, i will keep it simple to understand : 1) i have a database with 2 columns - word and text 2) Each word has approx. 600,000 lines of text associated with it. 3) Iam a .net person shifting to php and mysql - so a little knowledge. MY requirement : 1) I will pass the word through a form 2) The form will connect to the database and should display 2000 random lines from those 600,000 which should be non-repetitive My current progress : Code: [Select] <?php $con = mysql_connect("localhost","text_minx","pwd"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $result = mysql_query("SELECT * FROM Data WHERE word='health'"); while($row = mysql_fetch_array($result)) { echo $row['lines']; echo "<br />"; } ?> This shows all the lines. What i want is to read this $row['lines'] in a possible array and randomly select 2000 lines from it - and they should be non-repetitive. Any help please? Hey guys, any suggestions how i could read and write msWord files without using the COM interface. I need to keep all the formatting intact though... any ideas? many thanks hgey guys im trying to create a text based login but im having trouble to get the echo to show up on submit.php which is the form action page for signup.html. am not sure how i would make it showup on either file. <?php $myFile = "password.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $data= strip_tags($_POST['Username']); fwrite($fh,$data); fclose($fh); $File = "username.txt"; $fh2 = fopen($File, 'w') or die("can't open file"); $mydata = strip_tags($_POST['Password']); fwrite($fh2,$data); fclose($fh2); echo "You have Signed up Successfully Congrats!"; ?> HI, I have a ms-access file which has linked table. The linked table is connected to a ODBC source (e.g MS-SQL or 3rd Party ODBC Driver). WebPage(php) Apache, connecting to a ODBC DSN of MS-Access, MS-Access is having linked tables. Linked tables as from another ODBC source. On the PHP Page, When I am trying to connect the ms-access odbc dsn , I am able to connect. But when I query any of the linked tables, PHP is not able to query and is failing. Does php has capabilities to read/write to linked tables in ms-access file. Or it is issue with MS-Access Or is it I am missing something. Microsoft says, its an issue of PHP https://social.msdn....forum=accessdev Requesting you to please share your feedback Regards Rajendra Dewani <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Import a CSV File with PHP & MySQL</title> </head> <body> <form action="" method="post" enctype="multipart/form-data" name="csv" id="csv"> Choose your file: <br /> <input name="csv" type="file" id="csv" /> <input type="submit" name="Submit" value="Submit" /> </form> </body> when i input this code it only uploads a single column into my database
<html> <head> <title>MySQL file upload example</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body> <form action="try2.php" method="post" enctype="multipart/form-data"> <input type="file" name="uploaded_file"><br> <input type="submit" name="submit"value="Upload file"> </form> <p> <a href="list_files.php">See all files</a> </p> </body> <?php $con=mysqli_connect("localhost","root","","book"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } if(isset($_POST['submit'])) { $fname = $_FILES['uploaded_file']['name']; $chk_ext = explode(".",$fname); if(strtolower($chk_ext[1]) == "csv") { $filename = $_FILES['uploaded_file']['tmp_name']; $handle = fopen($filename, "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $sql = "INSERT into data(name,Groups,phone_number) values('$data[0]','$data[1]','$data[2]')"; $result=mysqli_query($con,$sql) or die(mysql_error()); } fclose($handle); echo "Successfully Imported"; } else { echo "Invalid File"; } } ?> </html> Goodevening.Thuis is the codes under these but i dont have any idea on how can i use it because i only use php and mysql as my database. i dont know how to use the xml as my database. can you help me? Thanks in advance
<?xml version="1.0" encoding="UTF-8" ?> <XMLDB PATH="plagiarism/programming/db" VERSION="20121207" COMMENT="XMLDB file for Moodle plagiarism/programming" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd" > <TABLES> <TABLE NAME="plagiarism_programming" COMMENT="This table saves settings for source code plagiarism detection in programming assignments" NEXT="plagiarism_programming_rpt"> <FIELDS> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="cmid"/> <FIELD NAME="cmid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The course module id" PREVIOUS="id" NEXT="scandate"/> <FIELD NAME="scandate" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="The date submissions are scanned" PREVIOUS="cmid" NEXT="jplag"/> <FIELD NAME="jplag" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="JPlag tool is used or not" PREVIOUS="scandate" NEXT="moss"/> <FIELD NAME="moss" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="MOSS tool is used or not" PREVIOUS="jplag" NEXT="language"/> <FIELD NAME="language" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="Which language is used in the assignment" PREVIOUS="moss" NEXT="auto_publish"/> <FIELD NAME="auto_publish" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" PREVIOUS="language" NEXT="notification"/> <FIELD NAME="notification" TYPE="char" LENGTH="200" NOTNULL="false" SEQUENCE="false" COMMENT="Used to display notifications to students" PREVIOUS="auto_publish" NEXT="starttime"/> <FIELD NAME="starttime" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="false" SEQUENCE="false" COMMENT="The time when last plagiarism scanning occurred" PREVIOUS="notification" NEXT="latestscan"/> <FIELD NAME="latestscan" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="false" SEQUENCE="false" COMMENT="timestamp of the latest scan" PREVIOUS="starttime" NEXT="notification_text"/> <FIELD NAME="notification_text" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="the customised notification text to appear on the student assignment page" PREVIOUS="latestscan"/> </FIELDS> <KEYS> <KEY NAME="primary" TYPE="primary" FIELDS="id"/> </KEYS> <INDEXES> <INDEX NAME="cmid_index" UNIQUE="false" FIELDS="cmid" COMMENT="Index for cmid for fast searching"/> </INDEXES> </TABLE> <TABLE NAME="plagiarism_programming_rpt" COMMENT="containing different report versions" PREVIOUS="plagiarism_programming" NEXT="plagiarism_programming_jplag"> <FIELDS> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="cmid"/> <FIELD NAME="cmid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" PREVIOUS="id" NEXT="time_created"/> <FIELD NAME="time_created" TYPE="int" LENGTH="15" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="cmid" NEXT="version"/> <FIELD NAME="version" TYPE="int" LENGTH="11" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" PREVIOUS="time_created" NEXT="detector"/> <FIELD NAME="detector" TYPE="char" LENGTH="10" NOTNULL="false" SEQUENCE="false" PREVIOUS="version"/> </FIELDS> <KEYS> <KEY NAME="report_primary" TYPE="primary" FIELDS="id" COMMENT="Primary key of the table"/> </KEYS> <INDEXES> <INDEX NAME="cmiverdet_index" UNIQUE="false" FIELDS="cmid, version, detector" COMMENT="Index for cmid, version, detector for fast searching"/> </INDEXES> </TABLE> <TABLE NAME="plagiarism_programming_jplag" COMMENT="containing JPlag scanning status of the lastest report" PREVIOUS="plagiarism_programming_rpt" NEXT="plagiarism_programming_moss"> <FIELDS> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="submissionid"/> <FIELD NAME="submissionid" TYPE="char" LENGTH="20" NOTNULL="false" SEQUENCE="false" PREVIOUS="id" NEXT="status"/> <FIELD NAME="status" TYPE="char" LENGTH="20" NOTNULL="false" SEQUENCE="false" PREVIOUS="submissionid" NEXT="directory"/> <FIELD NAME="directory" TYPE="char" LENGTH="200" NOTNULL="false" SEQUENCE="false" PREVIOUS="status" NEXT="message"/> <FIELD NAME="message" TYPE="char" LENGTH="200" NOTNULL="false" SEQUENCE="false" PREVIOUS="directory" NEXT="settingid"/> <FIELD NAME="settingid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="message" NEXT="progress"/> <FIELD NAME="progress" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="false" SEQUENCE="false" COMMENT="Show the progress (in percentage) of the current status" PREVIOUS="settingid" NEXT="token"/> <FIELD NAME="token" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false" COMMENT="Contain a random token for security when a child process is initiated. This token is then compared with the token passed in to ensure it is a valid call" PREVIOUS="progress" NEXT="error_detail"/> <FIELD NAME="error_detail" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="The detail of the error messages - for developer to see only" PREVIOUS="token"/> </FIELDS> <KEYS> <KEY NAME="primary" TYPE="primary" FIELDS="id"/> </KEYS> <INDEXES> <INDEX NAME="submissionid_index" UNIQUE="false" FIELDS="submissionid" COMMENT="Index for submissionid for fast searching"/> </INDEXES> </TABLE> <TABLE NAME="plagiarism_programming_moss" COMMENT="The table contains parameters and status for the last time the assignment is scanned with MOSS" PREVIOUS="plagiarism_programming_jplag" NEXT="plagiarism_programming_reslt"> <FIELDS> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="settingid"/> <FIELD NAME="settingid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="id" NEXT="resultlink"/> <FIELD NAME="resultlink" TYPE="char" LENGTH="200" NOTNULL="false" SEQUENCE="false" PREVIOUS="settingid" NEXT="status"/> <FIELD NAME="status" TYPE="char" LENGTH="20" NOTNULL="false" SEQUENCE="false" PREVIOUS="resultlink" NEXT="message"/> <FIELD NAME="message" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="status" NEXT="progress"/> <FIELD NAME="progress" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="false" SEQUENCE="false" COMMENT="The progress (in percentage) of the lattest MOSS scanning" PREVIOUS="message" NEXT="token"/> <FIELD NAME="token" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false" COMMENT="For verification of valid call when a forked process initiated by the main process. The token is first generated by the main process and stored in this field, and passed that token to the forked process. It is a valid call if the token passed is the same with the token stored" PREVIOUS="progress" NEXT="error_detail"/> <FIELD NAME="error_detail" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="Detail of the encountered error. Valid only when status=error" PREVIOUS="token"/> </FIELDS> <KEYS> <KEY NAME="primary" TYPE="primary" FIELDS="id"/> </KEYS> <INDEXES> <INDEX NAME="settingid_index" UNIQUE="false" FIELDS="settingid" COMMENT="Index for settingid for fast searching"/> </INDEXES> </TABLE> <TABLE NAME="plagiarism_programming_reslt" COMMENT="store the result of the scanning, each record contains a pair" PREVIOUS="plagiarism_programming_moss" NEXT="plagiarism_programming_cours"> <FIELDS> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="student1_id"/> <FIELD NAME="student1_id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" PREVIOUS="id" NEXT="student2_id"/> <FIELD NAME="student2_id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" PREVIOUS="student1_id" NEXT="additional_codefile_name"/> <FIELD NAME="additional_codefile_name" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="not null when the pair match is a comparison between a student and an additional code file" PREVIOUS="student2_id" NEXT="similarity1"/> <FIELD NAME="similarity1" TYPE="number" LENGTH="5" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" DECIMALS="2" COMMENT="similarity rate of student id 1" PREVIOUS="additional_codefile_name" NEXT="similarity2"/> <FIELD NAME="similarity2" TYPE="number" LENGTH="5" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" DECIMALS="2" COMMENT="similarity rate of student id 2" PREVIOUS="similarity1" NEXT="comparison"/> <FIELD NAME="comparison" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" PREVIOUS="similarity2" NEXT="comments"/> <FIELD NAME="comments" TYPE="char" LENGTH="150" NOTNULL="false" SEQUENCE="false" PREVIOUS="comparison" NEXT="reportid"/> <FIELD NAME="reportid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" COMMENT="foreign key to table programming_report" PREVIOUS="comments" NEXT="mark"/> <FIELD NAME="mark" TYPE="char" LENGTH="1" NOTNULL="false" SEQUENCE="false" COMMENT="used to mark a pair of assignment as having unusually high similarities" PREVIOUS="reportid"/> </FIELDS> <KEYS> <KEY NAME="pk_programming_result_id" TYPE="primary" FIELDS="id"/> </KEYS> <INDEXES> <INDEX NAME="repst1st2_index" UNIQUE="false" FIELDS="reportid, student1_id, student2_id" COMMENT="Index for reportid, student1_id, student2_id for fast searching"/> </INDEXES> </TABLE> <TABLE NAME="plagiarism_programming_cours" COMMENT="containing the courses which is enabled when level is set to global" PREVIOUS="plagiarism_programming_reslt" NEXT="plagiarism_programming_date"> <FIELDS> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="course"/> <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" PREVIOUS="id"/> </FIELDS> <KEYS> <KEY NAME="id" TYPE="primary" FIELDS="id" COMMENT="Primary key"/> </KEYS> <INDEXES> <INDEX NAME="course_index" UNIQUE="false" FIELDS="course" COMMENT="Index for course for fast searching"/> </INDEXES> </TABLE> <TABLE NAME="plagiarism_programming_date" COMMENT="containing the scheduled scan date of each enabled assignment. One assignment can have several scan date" PREVIOUS="plagiarism_programming_cours"> <FIELDS> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="scan_date"/> <FIELD NAME="scan_date" TYPE="int" LENGTH="20" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" PREVIOUS="id" NEXT="finished"/> <FIELD NAME="finished" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" PREVIOUS="scan_date" NEXT="settingid"/> <FIELD NAME="settingid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" PREVIOUS="finished"/> </FIELDS> <KEYS> <KEY NAME="date_primary" TYPE="primary" FIELDS="id" COMMENT="primary key"/> </KEYS> <INDEXES> <INDEX NAME="setfinsca_index" UNIQUE="false" FIELDS="settingid, finished, scan_date" COMMENT="Index for settingid, finished, scan_date for fast searching"/> </INDEXES> </TABLE> </TABLES> </XMLDB> Hello, I'm having some frustrations right now. I have built an application form where an applicant inputs their info and then uploads their resume. Even though the resume gets uploaded to a directory on the server i would also like the file name of the resume to get inserted into the mysql database so that I can easily see which resume matches which applicant...if that makes sense. At any rate I'm able to get everything else to work, the applicant's info gets inserted into the database, the resume gets uploaded to the directory, i just can't seem to get the resume file name to also insert into the database. Most of the info i have found on this subject through googleing and the like has been a little over my head and/or a little more complex than what i'm looking for. Here is an extremely simplified version of what I have right now. I have excluded the 'connect to database' code since it's working fine and really doesn't have anything to do with this issue: Code: [Select] <?php $target_path = "docs/"; $target_path = $target_path . basename( $_FILES['resume']['name']); $first_name=$_POST['first_name']; $last_name=$_POST['last_name']; $middle_init=$_POST['middle_init']; $resume=$_POST['resume']; mysql_query("INSERT INTO `intern` VALUES ('$first_name', '$last_name', '$middle_init', '$resume')") ; if (move_uploaded_file($_FILES['resume']['tmp_name'], $target_path)); ?> HTML begins after that. At any rate, any info, help, etc. you could provide would be GREATLY appreciated! Thanks! Hi friends i need a small help in importing csv files into mySQL database table i tried all possible options but i am no where... here is the example for what i am trying to do Mysql DB name = raw Table name is = dump +--------------------+--------------------+ + Account + Bal + +--------------------+--------------------+ + + + +--------------------+--------------------+ CSV Format 50************13, 11095 When they upload the file it should automatically get inserted into appropriate fields any help would be great i tried all possible scripts found in the net could nothing is happening hi- i'm trying to browse for a CSV file and then upload it to my mysql database. i found the code below and not working. i don't get any errors. the connection to the database is ok bcz i get the existing results but not the ones from the CSV file added to the db.. any ideas? Code: [Select] <?php ob_start(); require_once('../../connections/congif.php'); mysql_select_db($dbname, $db); $sql_get_project="SELECT * FROM gifts_tbl ORDER BY autoID DESC LIMIT 25"; $get_project = mysql_query($sql_get_project, $db) or die(mysql_error()); $row_get_project = mysql_fetch_assoc($get_project); //database connect info here //check for file upload if(isset($_FILES['csv_file']) && is_uploaded_file($_FILES['csv_file']['tmp_name'])){ //upload directory $upload_dir = "csv_dir/"; //create file name $file_path = $upload_dir . $_FILES['csv_file']['name']; //move uploaded file to upload dir if (!move_uploaded_file($_FILES['csv_file']['tmp_name'], $file_path)) { //error moving upload file echo "Error moving file upload"; } //open the csv file for reading $handle = fopen($file_path, 'r'); //turn off autocommit and delete the product table mysql_query("BEGIN"); while (($data = fgetcsv($handle, 1000, ',')) !== FALSE) { //Access field data in $data array ex. $name = $data[0]; //Use data to insert into db $sql = sprintf("INSERT INTO gifts_tbl (player_id) VALUES ('%s)", mysql_real_escape_string($name) ); mysql_query($sql) or (mysql_query("ROLLBACK") and die(mysql_error() . " - $sql")); } unlink($file_path); } ob_flush(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Gifts</title> </head> <body> <h1>Testing for CSV upload</h1> <form action="" method="post"> <input type="file" name="csv_file"> <input type="submit" name="csv_submit" value="Upload CSV File"> </form> <h2>Results</h2> <?php do { ?> <ul> <li><?php echo $row_get_project['player_id']; ?></li> </ul> <?php } while ($row_get_project = mysql_fetch_assoc($get_project)); ?> </body> </html> |