PHP - Flat File Database
Hi, I use MySQL for real projects of course... but, I like to challenge myself and I was wondering how people make advance applications with Flat File databases... My questions are...
>Display >Reading The Flat File Data >Sorting it Alphabetically For Display >How to create a WHERE clause affect with the data >Storage >Adding Records >Deleting Records >Editing Records I went over a lot of this on my own, but I'm stuck on certain parts because google only has so much on Flat File Databases... also how would u secure a Flat File Database from someone just simply direct linking to it and viewing it? Similar Tutorialsit is displaying the lastnames in the order they are in the profile but do not know how to get it to sort by lastname - please help <?php $lines = file('database/profile.txt'); foreach($lines as $thisline){list($p_id,$p_status,$p_filestart,$p_filemodified,$p_first,$p_middle,$p_last,$p_nick) = explode('|',$thisline);{ $names []= $p_last.', '.$p_first.' '.$p_middle.'.'; foreach($names as $value); {echo ''.$value.'<br>';}}} ?> Hello Mates, I am in need of help. I have a Flat File News Script. I am not sure how to build the Delete script.. i am not knew to PHP but kinda new to Flat File Database.. the reason why im using FFD is because my service doesn't allow mysql on the cheaper priced web pages.. i have 4 fields ID || user_name || title || message i want it to check the id because it will be in the url like http://webpage.com/delete_news.php?id=3 and the id 3 and the other fields in id 3 is deleted. Thank you Valkeri2010 I am creating a guestbook for a friend who has access to a hosting server for free, however they are reluctant to let us create databases so i have used a flat file system to create a simple login and register system. On this site I have also included a flatfile guestbook, I've not coded this from scratch as I'm just not php freak enough for it. The guestbook requires a name and email address to submit a post, i would like to change this so that it takes the details straight from the flatfile and not be displayed at all if there is no-one logged in. Guestbook.php <?php // find out the domain: $domain = $_SERVER['HTTP_HOST']; // find out the path to the current file: $path = $_SERVER['SCRIPT_NAME']; $url = "http://" . $domain . $path ; extract($_POST); if($Submit){ $date = date('D d Y h:i'); $comment=eregi_replace("\r\n","*",$comment); $comment=eregi_replace("\n","*",$comment); $fp = fopen("bin/guestbook.nfo","a+"); if(!$fp) { echo 'Error: Cannot open file.'; exit; } fwrite($fp, $date."||".$name."||".$email."||".$comment."\n"); fclose($fp); } ?> <div align="center"> <h2><span class="style1">Guestbook </span><br> </h2> </div> <form name="form1" method="post" action="<?php echo $url;?>"> <label>Name <input type="text" name="name"> </label> <label>Email <input type="text" name="email"> </label> <p> </p> <p> comment<br> <textarea name="comment" cols="40" rows="10"></textarea> <br> <label> <input type="submit" name="Submit" value="Sign"> </label> <br> </p> </form> <hr> <?php $userinfo = file("cgi-bin/guestbook.nfo"); echo '<table border="0">'; foreach($userinfo as $val) { //explode that data into a new array: $data = explode("||", $val); echo '<tr><td>'.$data[0].'</td></tr>'; echo '<tr><td>'.$data[1].' Wrote:</td></tr>'; $data[3]=eregi_replace("\*","<br>",$data[3]); echo '<tr><td>'.$data[3].'</td></tr>'; echo '<tr><td>Email:'.$data[2].'<hr></td></tr>'; } echo '</table>'; ?> This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=315620.0 Given this script: <?php $file = file('info.txt'); $statelist = array (1=> "California", "Florida", "Illinois", "New York", "Texas"); foreach ($file as $line => $data) { list($state, $abbrev, $population) = explode('|', trim($data)); for ($x=1; $x<5; $x++) { if ($statelist[$x] == $state) { echo $state . ", " . $abbrev . " - " . $population . '<br />'; } } } ?> and this flat file (info.txt): Code: [Select] California|CA|36,756,666 Texas|TX|24,326,974 New York|NY|19,490,297 Florida|FL|18,328,340 Illinois|IL|12,901,563 This is what is outputted: Code: [Select] California, CA - 36,756,666 Texas, TX - 24,326,974 New York, NY - 19,490,297 Florida, FL - 18,328,340 Illinois, IL - 12,901,563 How can I sort the output by the index value of the "statelist array" so get this output: Code: [Select] California, CA - 36,756,666 Florida, FL - 18,328,340 Illinois, IL - 12,901,563 New York, NY - 19,490,297 Texas, TX - 24,326,974 Could ksort($statelist) be implemented? I currently have a flat file user registration and login in system. I also have a simple guestbook which i didn't code myself, the guest book currently requires the user to type in there name and e-mail address to make a post. how ever i would like them to have to login and if they aren't logged in then don't display the guestbook. Live version: B50crew.co.uk Guestbook.php: Code: [Select] <?php // find out the domain: $domain = $_SERVER['HTTP_HOST']; // find out the path to the current file: $path = $_SERVER['SCRIPT_NAME']; $url = "http://" . $domain . $path ; extract($_POST); if($Submit){ $date = date('D d Y h:i'); $comment=eregi_replace("\r\n","*",$comment); $comment=eregi_replace("\n","*",$comment); $fp = fopen("bin/guestbook.nfo","a+"); if(!$fp) { echo 'Error: Cannot open file.'; exit; } fwrite($fp, $date."||".$name."||".$email."||".$comment."\n"); fclose($fp); } ?> <div align="center"> <h2><span class="style1">Guestbook </span><br> </h2> </div> <form name="form1" method="post" action="<?php echo $url;?>"> <label>Name <input type="text" name="name"> </label> <label>Email <input type="text" name="email"> </label> <p> </p> <p> comment<br> <textarea name="comment" cols="40" rows="10"></textarea> <br> <label> <input type="submit" name="Submit" value="Sign"> </label> <br> </p> </form> <hr> <?php $userinfo = file("cgi-bin/guestbook.nfo"); echo '<table border="0">'; foreach($userinfo as $val) { //explode that data into a new array: $data = explode("||", $val); echo '<tr><td>'.$data[0].'</td></tr>'; echo '<tr><td>'.$data[1].' Wrote:</td></tr>'; $data[3]=eregi_replace("\*","<br>",$data[3]); echo '<tr><td>'.$data[3].'</td></tr>'; echo '<tr><td>Email:'.$data[2].'<hr></td></tr>'; } echo '</table>'; ?> Login: Code: [Select] <?php // find out the domain: $domain = $_SERVER['HTTP_HOST']; // find out the path to the current file: $path = $_SERVER['SCRIPT_NAME']; $url = "http://" . $domain . $path ; extract($_POST); if($Submit){ $date = date('D d Y h:i'); $comment=eregi_replace("\r\n","*",$comment); $comment=eregi_replace("\n","*",$comment); $fp = fopen("bin/guestbook.nfo","a+"); if(!$fp) { echo 'Error: Cannot open file.'; exit; } fwrite($fp, $date."||".$name."||".$email."||".$comment."\n"); fclose($fp); } ?> <div align="center"> <h2><span class="style1">Guestbook </span><br> </h2> </div> <form name="form1" method="post" action="<?php echo $url;?>"> <label>Name <input type="text" name="name"> </label> <label>Email <input type="text" name="email"> </label> <p> </p> <p> comment<br> <textarea name="comment" cols="40" rows="10"></textarea> <br> <label> <input type="submit" name="Submit" value="Sign"> </label> <br> </p> </form> <hr> <?php $userinfo = file("cgi-bin/guestbook.nfo"); echo '<table border="0">'; foreach($userinfo as $val) { //explode that data into a new array: $data = explode("||", $val); echo '<tr><td>'.$data[0].'</td></tr>'; echo '<tr><td>'.$data[1].' Wrote:</td></tr>'; $data[3]=eregi_replace("\*","<br>",$data[3]); echo '<tr><td>'.$data[3].'</td></tr>'; echo '<tr><td>Email:'.$data[2].'<hr></td></tr>'; } echo '</table>'; ?> Session.php <?php class user { var $file_dir = ""; function start($time = 3600) { session_set_cookie_params($time , ''); session_name('afroxav-login'); session_start(); // Reset the expiration time upon page load if (isset($_COOKIE['afroxav-login'])) { setcookie('afroxav-login', $_COOKIE['afroxav-login'], time() + $time, '', 'localhost', 0, 1); } if (!isset($_SESSION['info'])) { $this->data = array('name' => 'Anonymous', 'logged' => false); } else { $this->data = $_SESSION['info']; } } function check_login() { if ($this->data['logged'] !== true) { return false; } else if ($this->data['logged'] === true) { if ($this->data['name'] !== 'Anonymous') { return true; } return false; } return false; } function login($user, $pass) { $logins_raw = @file_get_contents($this->file_dir . 'users.php'); $logins_processed = str_replace('<?php exit; ?>', '', $logins_raw); $logins_array = explode('\n', $logins_processed); foreach ($logins_array as $id => $line) { $logins[$id] = explode('|', $line); } $pass = $this->hash_pass($pass); foreach ($logins as $user_info) { if ($user_info[1] == $user) { if ($user_info[2] == $pass) { $this->update_session($user_info); return true; } } } return false; } function hash_pass($string) { return hash('sha512', $string); } function logout() { $_SESSION['info'] = array('name' => 'Anonymous', 'logged' => false); $this->data = $_SESSION['info']; return true; } function prep_reg_array($name, $pass, $email, $mod = 'false', $admin = 'false') { $id_raw = @file_get_contents($this->file_dir . 'id.php'); $id = str_replace('<?php exit; ?>', '', $id_raw); $id = $id + 1; @file_put_contents($this->file_dir . 'id.php', '<?php exit; ?>' . $id); return array($id, $name, $this->hash_pass($pass), $email, $mod, $admin); } function register($userdata) { $write = file_put_contents($this->file_dir . 'users.php', '\n' . implode('|', $userdata), FILE_APPEND); return ($write !== false) ? true : false; } function update_session($array) { $_SESSION['info'] = array( 'id' => $array[0], 'name' => $array[1], 'pass' => $array[2], 'email' => $array[3], 'mod' => $array[4], 'admin' => $array[5], 'logged' => true ); $this->data = $_SESSION['info']; } }; //html related functions //not related at all with the sessions function html_start($title) { header('Content-type: text/html'); echo "<html>\n"; echo "<head>\n"; echo "<title>\n"; echo $title; echo "</title>\n"; echo "</head>\n"; echo "<body>\n"; echo "<h1>\n"; echo $title; echo "</h1>\n"; } function html_nav() { global $user; echo "<div>\n"; echo "Navigation\n"; echo "<ul>\n"; echo "<li><a href=\"?page=home\">Home</a></li>\n"; if ($user->check_login() == true) { echo "<li><a href=\"?page=logout\">Log Out</a></li>\n"; } else { echo "<li><a href=\"?page=login\">Log In</a></li>\n"; echo "<li><a href=\"?page=register\">Register</a></li>\n"; } echo "</ul>\n"; echo "</div>\n"; } function html_end() { echo "</body>\n"; echo "</html>\n"; } ?> I want to make the news feed on my website easier to maintain. I just created a form that I will use to add the information. The form saves the files that it creates as "entry-date-time.txt" and places it in a folder for the year and a sub folder for the month. Such as "2011\09". I have displayed data from a single flat file before, but I am unsure how to go about displaying the data from multiple files. Can anyone show me an example? I want to be able to paginate the data, displaying a number of updates per page from newest to oldest. I don't have MySQL access on the server or I'd just use that, instead. Folks, I have a flat file or CSV, which has the tree structure of the Nesed Categories (All are delimited by either > or tab, it can be set easily). I want a PHP/Mysql code/routine that i can automaticaly create a table in MYsql with Parent Child relationship. Logic is there in my mind, every distinct Node will be an ID which while every child node will have the PID (parent ID) of its Parent. So the below data from flat file (Actual Data can be N Level Deep at least 4 Level): Electronics Electronics > Phones Electronics > Phones > Iphone Electronics > Phones > LG Electronics > Phones > Samsung Electronics > Phones > Samsung > 3G Electronics > Laptops Electronics > Laptops > Dell Electronics > Laptops > Sony Electronics > Laptops > HP Electronics > Laptops > HP > Core 2 Duo Will look like this in Mysql Table Structu Quote http://pastie.org/1592730 This is the Logic i need ot adopt, but i have no clue on how to code it to extract in this table structure and define this paren tchild mapping automatically. Can someone Help me out wiht this? Cheers Natasha T This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=333509.0 I have a login system that uses a flat file database. The flat file is in a directory outside the public_html. My questions; 1- Is is still possible to hack into that file? Currently I do not encrypt the passwords as I have been told that having the file outside the public_html makes the file unavailable to the public. This allows me the advantage of sending the Username and Password to the user in an email if they forget there password or username. Otherwise- I would have to set up a more complicated method to allow them to change their password to re-gain access to the site. I have an SSL on the site also so I am not worried about packet sniffing. Thanks I am pretty new to php and trying to teach myself. I can't get the values from this form to write to my flat file called orders.txt: browse_index.php <?php include("includes/menu_members.php") ?> <div id="content"> <h1>SHOPPING CART</h1> <a href="browse_index.php">CLICK HERE TO CONTINUE SHOPPING</a> <?php echo ' <table border="0"> <tr> <td><form id="f2" method="post"name="f2"><input type="submit" action="order_summary.php" name="submit2" value="submit order"></td> '; if(isset($_POST['submit'])) { $itemname = $_POST['h1']; //echo $_SESSION['itemname'][$itemname]; unset($_SESSION['itemqty'][$itemname]); unset($_SESSION['itemprice'][$itemname]); unset($_SESSION['itemname'][$itemname]); } echo "<br/><br/>"; echo "<table border='8' bgcolor='#efefef'>"; echo "<tr><th>Name</th><th>Quantity</th><th>Price</th><th>Subtotal</th></tr>"; foreach($_SESSION['itemname'] as $key=>$value) { echo '<tr><td><b>'.$_SESSION['itemname'][$key].'</b></td> <td>'.$_SESSION['itemqty'][$key].'</td> <td>$'.$_SESSION['itemprice'][$key].'</td> <td name="subtotal">$'.($_SESSION['itemqty'][$key] * $_SESSION['itemprice'][$key]).'</td> <td><form id="f1" method="post" name="f1"><input type="submit" name="submit" value = "delete"><input type="hidden" name="h1" value='.$key.'></td></tr>' ; } ?> order_summary.php: <?php session_start (); $date = date ("H:i jS F"); $outputstring = $date."/t" .$_POST['h1']. ":" .$_SESSION['itemqty'][$key]. ":" .$_SESSION['subtotal'][$key]. ":" ."\n"; $fp = fopen("orders.txt","a"); fwrite($fp, $outputstring); fclose($fp); ?> Can someone direct me where I am going wrong??? Hi guys, is there anyway to process this $result from a mysql query inside PHP so that the data below will be formatted to a pivot-like table? The number of rows and columns of the output 'table' will be indefinite. Thanks so much! Data: ID Row Col Name 1 1 A A1 2 2 A A2 3 3 A A3 4 1 B B1 5 2 B B2 6 3 B B3 7 1 C C1 8 2 C C2 9 3 C C3 Results: A1(1) A2(2) A3(3) B1(4) B2(5) B3(6) C1(7) C2( C3(9) How can I use PHP to export my database into a .sql file? how do I use a connection file (connection.php) in multiple programs? I think include? I want to make a time limit in-between posts on my forum. Should I make a table in the database to store the seconds, or read it/write via a file? Hi PHP freaks!!
I have manage to make a script to upload file in database and its working. I will share to you the codes so for other viewers and readers to use also.
if($result){ if($_FILES['LRCard']['name'] != ""){ $filename = $_FILES['LRCard']['name']; $ext = strrchr($filename,"."); $LRCardname = $student_id; $LRCardname .="_". $filename; if($ext ==".jpg" || $ext ==".jpeg" || $ext ==".JPG" || $ext ==".JPEG" || $ext ==".gif" || $ext ==".GIF"){ $size = $_FILES['LRCard']['size']; if($size > 0 && $size < 5000000){ $archive_dir = "LRCards"; $userfile_tmp_name = $_FILES['LRCard']['tmp_name']; if(move_uploaded_file($userfile_tmp_name, "$archive_dir/$LRCardname")){ /* if LRC is successfully uploaded then LRC is stored in database. */ mysql_query("update student_information set LRCard='$LRCardname' where student_id='$student_id'", $link_id); $flag = "success"; if(mysql_error()!=null){ die(mysql_error()); } } else{ if(file_exists('LRCard/' . $LRCardname)) { unlink('LRCards/' . $LRCardname); } rollbackData(); } } else{ if(file_exists('LRCards/' . $LRCardname)) { unlink('LRCard/' . $LRCardname); } rollbackData(); die("You can upload LRCard of 5 MB size only. Please, try again."); } } else{ if(file_exists('LRCards/' . $LRCardname)) { unlink('LRCards/' . $LRCardname); } rollbackData(); die("You can upload LRCard of .jpg, .jpeg, .gif extensions only. Please, try again. "); } } } else{ $flag="error"; } if($flag == "success"){ mysql_query(" COMMIT "); $flag="success"; if(mysql_error() != null){ die(mysql_error()); } }Now, my problem is how to make a Php script to DOWNLOAD this uploaded file considering the 1. file path 2. file name 3. file extension. 4. student_id (to determine the specific file from a specific student) My plan is to make a download button which hyperlink to download.php and after clicking that button the specified file to a specific student id will automatically be downloaded by the browser. Hey anybody can please guide me where I m wrong in this php code please reply here is the code Only variables should be passed by reference on line 3 in that function area function get_file_extension($file_name) main error I guess is the explode one Aand yeah I checked adding $file_name = $_FILES['fld']; before the function is started <?php require("include/dbconn.php"); //$username = mysql_real_escape_string($_POST['username1']); function get_file_extension($file_name) { return end(explode('.',$file_name)); } function errors($error){ if (!empty($error)) { $i = 0; while ($i < count($error)){ $showError.= '<div class="msg-error">'.$error[$i].'</div>'; $i ++;} return $showError; }// close if empty errors } // close function if (isset($_POST['submit'])){ $username = "Sunny"; $date1 = date("d m y"); mysql_select_db("deals") or die(mysql_error()); if($username == "") { //header("location:newnewuser1.php"); echo "Username empty"; //header("location:newnewuser1.php"); } else { function createRandomPassword() { $chars = "abcdefghijkmnopqrstuvwxyz023456789"; srand((double)microtime()*1000000); $i = 0; $pass = '' ; while ($i <= 7) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $pass = $pass . $tmp; $i++; } return $pass; } // Usage $password = createRandomPassword(); //$password = mysql_real_escape_string($_POST['Password']); $date = strtotime("+2hours"); $date1 = date("d-m-y",$date); if(get_file_extension($_FILES["fld"]["name"])!= 'csv') { $error[] = 'Only CSV files accepted!'; echo "Wrong Input"; }//get_file_extension if (!$error) { $tot = 0; $handle = fopen($_FILES["fld"]["tmp_name"], "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { for ($c=0; $c < 1; $c++) { try { mysql_query("INSERT INTO newusers (email,password,location,company,name,contact,sourcename,date)VALUES('".mysql_real_escape_string($data[0])."','$password','".mysql_real_escape_string($data[1])."', '".mysql_real_escape_string($data[2])."','".mysql_real_escape_string($data[3])."','".mysql_real_escape_string($data[4])."','$username1','$date1')"); $tot++; } catch(Exception $e) { PRINT 'ERROR:' +$e; } }//for }//while fclose($handle); }// end no error }//close if isset upfile } ?> and this is the form code <form name="f1" action="" method="POST" enctype="multipart/form-data"> <table><tr><td><input type="file" value="Browse" name="fld" onselect="CheckExtension(fld)"><br/></td><td> </td></tr><tr><td>Username :<input type="text" name="username1" value="" id="user" onfocus="validateForm1()"></td> <td><input type="submit" name="submit" value="submit" id="submit"></td></tr></table> </form> Please help me I m stuck in this quite badly Please [attachment deleted by admin] 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> As per the client requirement he wants to read words from a file and want to insert them in database one by one . ie a confirmation is required whether he wants to insert is or not. I have developed the thing but the problem is when i am retrieving the words it asks for all the words. i will show u wat the problem is. My main query is i want to pause the exectution until user's input. Code: [Select] <script type="text/javascript" src="jquery.js"></script> <script type"text/javascript"> function show() { document.getElementById('form#submit').fadeIn(); alert("Abhinav"); } $(document).ready(function(){ $("form#submit").submit(function() { // we want to store the values from the form input box, then send via ajax below var word = $('#word').attr('value'); var synonym = $('#synonym').attr('value'); $.ajax({ type: "POST", url: "ajax.php", data: "word="+ word + "&synonym=" + synonym, success: function(){ $('form#submit').hide(); //$('form#submit :input').val(""); $('div.success').fadeIn(); } }); return false; }); }); </script> <?php $file=fopen("welcome.txt","r") or exit("Unable to open file!"); @$word=""; @$c=""; while (!feof($file)) { $c=fgetc($file); if(strcmp($c," ")==0) { echo "". "<form id='submit' method='post' name='submit' action='' >". "<fieldset> ". "<legend>Enter Information</legend> ". " <label for='word'>Word:</label> ". "<input id='word' class='text' name='word' size='20' type='text' value='$word' > ". " <label for='Synonym'>Synonym:</label> ". "<input id='synonym' class='text' name='synonym' size='20' type='text'> ". " <button class='button positive' type='submit'> Add Client </button> ". " </fieldset> ". " </form> ". "<div class='success' style='display:none;'>Client has been added.</div> ". "</div>"; $word=""; } else $word=$word.$c; } fclose($file); ?> Now what i want is after user clicks add client then only next insertion box must be shown. please check the attached image to see the output. Guys pls help me over this. Thnx in advance Here is my code in admin_common.php. This is a website I had over at yahoo that I moved to Godaddy. define("EZSQL_DB_USER", "larryadmin"); // <-- mysql db user define("EZSQL_DB_PASSWORD", "mypassword"); // <-- mysql db password define("EZSQL_DB_NAME", "larryadmin"); // <-- mysql db pname define("EZSQL_DB_HOST", "mysql"); // <-- mysql server host I keep getting this error SQL/DB Error -- [ Error establishing a database connection! Are you sure you have the correct user/password? Are you sure that you have typed the correct hostname? Are you sure that the database server is running? ] SQL/DB Error -- [ Error selecting database larryadmin! Are you sure it exists? Are you sure there is a valid database connection? ] Please help thanks. |