PHP - I Am Tired, So I Might Be Missing Somthing. What Is There A Space Added?
My Code is suppose to parse a text file and return the value that is attached to the variable. However when I try calling two different variables, one after the next, it adds a space.
Here is the code: <?php define("FILE", "config/review_setup.txt"); function fix($var){ $var = strtolower($var); return str_replace(" ", "_", $var); } function findValue($var, $file = FILE){ $var = fix($var); $val = NULL; $fh = fopen(FILE, "r"); while(!feof($fh)){ $string = fgetss($fh); $i = stripos($string, "="); $f_var = str_replace(" ", "", substr($string, 0, $i) ); if($f_var == $var){ $val = str_replace("\"", "", substr($string, $i+1, strlen($string)) ); $val = str_replace(" ", "", $val); break; } } if(is_null($val)) $val = "DNE"; fclose($fh); } echo findValue("host"); echo findValue("port"); ?> Output of above: Quote smtp1.servage.net 25 if I just do host, I get this: Quote smtp1.servage.net Any thoughts? Similar TutorialsHey everyone this is really really simple. say my site is www.mywebsite.com in my index page I have this define('PHPSITE_DIR', 'mywebsite'); require_once(PHPSITE_DIR . '/test/hello.php'); I have a folder named test and inside the folder i have hello.php but when i go to www.mywebsite.com i get Code: [Select] Warning: require_once(mywebsite/test/hello.php) [function.require-once]: failed to open stream: No such file or directory in wtf? i'm using godaddy server if that matters I finished a template engine, its tiny, needed it for a small project. so with that in mind I am stuck on adding a new section that is not going well. tag: {subgame} this will show the layout of a particular game - works fine yippe! but that is just for one game. so now I am changing it to show more than one, and I cannot use that tag over, due to the way "str_replace" works (changes all in one swoop) so I thought doing it this way 2nd Method: {subgame1} {subgame2} {subgame3} etc... the search is: where field is one of the triggers (in this case SUBGAME) Code: [Select] if (strstr( '{'.$field.'}",$html_str) ) works fine for the first one, but obviously ignores the 2nd method I tried preg_match - but i know i am missing something, because I cannot get it to work. and ideal way would be the fnmatch( as of 5.3 its available for windows now) but only supports up to 260 characters - not good for website So what I am looking for: psuedo code: Code: [Select] if ( '{'.$field.'[optional digits]}' ) { do code here } I know preg_match seems to be the way but cant get it to see the numbers and if it does, it misses the origianl game, or worse crashes. hi guys i have been building a website and have added a contact form and PHP script to send me a email server side the script works as it it will refresh the pages and display my thank you message but no email ever turns up my email address is correct so there must be somthing else not working <?php /*Email Varibles*/ $emailSubject = 'media-ondemand-contact.php'; $webMaster = 'alextrashacc@hotmail.com'; /*Data Varibles*/ $email = $_POST['email']; $name = $_POST['name']; $radiobuttons = $_POST['radiobuttons']; $where = $_POST['where']; $comments = $_POST['comments']; $newsletter = $_POST['newsletter']; $body = <<<EOD <br><hr><br> Email: $email <br> Name: $name <br> Suggestions Ect: $radiobuttons <br> Where did you hear about us: $where <br> Comments: $comments <br> News Letter Sign up: $newsletter $headers = "$email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); EOD; $theResults = <<<EOD <html> <head> <meta http-equiv="refresh" content="3;//media-ondemand.com"> <title>Sent Message</title> <style type="text/css"> <!-- body { text-align: center; font-family: Verdana, Geneva, sans-serif; font-size: 36px; font-weight: bold; font-variant: normal; color: #666; } --> </style> </head> <body> <p>Thank You</p> <p> Your Message Has Been Sent </p> </body> </html> EOD; echo "$theResults"; ?> the contact page is at www.media-ondemand.com/contact.html <?php $result = mysql_query ("SELECT genre FROM genres ORDER BY genre"); while ($row = mysql_fetch_row($result)) { echo "<tr>"; for ($i =0; $i<5; i++) { foreach ($row as $genre) echo "<td><input type='submit' name='listMovies' value='" .$genre ."'></td>"; } echo "</tr>"; } ?> ok i'm getting a single line of submit buttons for this output. i want there to be 5 buttons in a row. it seems like i have done this before with the for loop i have, but something is not working right. i know it will have to be a for loop, i just can't figure out where to start it. i know there are 1000 different ways to get the buttons on the screen, but i want to do it with the submit buttons. the best i can get is 5 columns of the same thing i'm outputting now. thanks in advance, i know this is a no-brainer. i just don't have a brain atm So I wanted to create stickers on my forum where people type in say ":Blobby-Tired" and then instead of the comment showing ":Blobby-Tired" it shows an html image tag displaying a picture of Blobby in the comment box So I created the following page CommentUpload.php However my sql fails to insert it despite the fact when I "echo $new" it shows the image on the page correctly And it can't be my sql insert code as if I change $new variable for "$BodyText" int he SQL query it it inserts ":Blobby-Tired" OK?
<?php include 'dbconnect.php'; session_start(); if(isset($_POST["submit"]) && !empty($_POST["CommentText"])){ $id = intval($_SESSION['id']); echo $_SESSION['id'] . '<p> </p>' ; $BodyText = $conn -> real_escape_string($_POST['CommentText']) ; $User = $_SESSION['username']; //Replace flairs with <img> tags /*not working currently) */ $new = str_replace(":Blobby-Tired","<img src='flairs/Blobby-Tired.jpg'> </img>","'$BodyText'"); echo "$new"; /************************/ $sql = "INSERT INTO Posts (User, CommentText, IdOfThread) VALUES ('$User','$new','$id')"; if (mysqli_query($conn, $sql)) { echo "New record has been added successfully !"; } else { echo "Error: " . $sql . ":-" . mysqli_error($conn); } mysqli_close($conn); } ?> Edited April 28 by Fishcakes I have a table with postcodes in it. At some point some of the codes will be entered with spaces (LA12 5TH) and some without (LA17HU) what i need is a function to check if there is a space, if not - count back 3 characters from the end of the string and insert a space. I don't know which string function to use - looked at pad but that seems to be for either end of string and not the middle - any ideas? this is my first post so I hope someone can help find a solution to this problem. I created this website in wordpress www.porthopehealthcentre.com It displayed correct in firefox but not ie. There was an extra closing </div> tag in my header php. I deleted this and now it displays correct in ie but not firefox. Can I somehow link to two different header files one for ie and one for firefox? if so how do I do this? Or is there an easier solution to this. I would really appreciate someones help as this is the final thing that needs adjusting to finish the job. Hi, Im building a management web application that can contain sensitive information for people, allow for cheques to be printed, amoung other things. Im wondering what are some extra security features that could be added as some users may not want to have the web application available outside their business. I would preffer doing this without having to run the server locatlly on thier machine. i was thinking something like only allowing certain ip address's to access the sites login. Anyone have any other/better ideas? For some reason this only allows one SQL to be added... // SQL Connection $username="monstert_admin"; $password="admin"; $database="monstert_admin"; $connection = mysql_connect("localhost", $username, $password) or die("Connection Failure to Database"); // Select Database mysql_select_db($database, $connection) or die ($database . "No Database" . $username); //Select everything from the the table $MyQuery = "SELECT * FROM photos"; $retrieve = mysql_query($MyQuery) or die(mysql_error()); if(mysql_num_rows($retrieve) != 0): $row = mysql_fetch_assoc($retrieve); else: echo ''; endif; if(isset($_POST['Submit']) && !$errors) { $url = $newname; include('img.php'); $image = new SimpleImage(); $image->load($url); $image->resize(500,315); $image->save($newname); mysql_query("INSERT INTO photos (url) VALUES ('$url')"); echo "File Uploaded Successfully as <i> "; echo $newname; echo "</i>"; } What would the issue be? I only have two columns - ID and url Thanks in advance! I got two values from a form in a page by POST method. Now I want to add this values to a text file. The code of form1.htm is like this: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <form action="write1.php" method="post"> <fieldset> <legend>Log In...</legend> <input type="text" name="uname" /><br> <input type="text" name="pass" /><br><br> <input type="submit" name="button" value="Log In" /> </fieldset> </form> </body> </html> And the code of write1.php is like this: <?php function arr_func() { $name = $_POST['uname']; $pass = $_POST['pass']; //trying to catch values in an array $arr[] = array("name"=>"$name", "pass"=>"$pass"); foreach ($arr as $val_arr) { foreach ($val_arr as $key=>$val) { echo "$key - $val<br>"; } echo '<br>'; } } $arr1 = arr_func(); //values are printed, no problem echo $arr1; //trying to change the array into string, is it wrong approach? $var1 = strval($arr1); // set file to write $file = 'student/dump.txt'; // open file $fh = fopen($file, 'w') or die('Could not open file!'); // write that variable into file fwrite($fh, "$var1\n") or die('Could not write to file'); // close file fclose($fh); ?> After log in in form1 I get two values of $name and $pass in write1.php but no values being added to the file mentioned in the path. I have a membership site that a user creates a username and password at registration. The user logs in and all that works. The usersname is located in the database under users. Each page is protected and you must login to access it. Here is the code for that
checkLogin('2'); $getuser = getUserRecords($_SESSION['user_id']);If the user login is correct they have access to the page. This all works fine as I said. On this page is a form that gets filled out. All the data except the username is added to the database for the contents of this form. I need to have the username added to the database to track who the data belongs to. Here is the code I have for this, can some tell me where I messed up. The line under the the code <body> pulls the username and the echo command prints the username on the page. I repeated this code under the if ($_SERVER['REQUEST_METHOD'] == "POST") code and it also prints the username. <?php // this is processed when the form is submitted // back on to this page (POST METHOD) if ($_SERVER['REQUEST_METHOD'] == "POST") { $usernow = $getuser[0]['username']; $userid = $usernow; echo "$userid"; # escape data and set variables $userid = addslashes($_POST["userid"]); $date = addslashes($_POST["date"]); $temperature = addslashes($_POST["temperature"]); $ph = addslashes($_POST["ph"]); $ammonia = addslashes($_POST["ammonia"]); $nitrite = addslashes($_POST["nitrite"]); $nitrate = addslashes($_POST["nitrate"]); $phosphate = addslashes($_POST["phosphate"]); $gh = addslashes($_POST["gh"]); $kh = addslashes($_POST["kh"]); $iron = addslashes($_POST["iron"]); $potassium = addslashes($_POST["potassium"]); $notes = addslashes($_POST["notes"]); // # setup SQL statement $sql = " INSERT INTO water_parameters "; $sql .= " (id, userid, date, temperature, ph, ammonia, nitrite, nitrate, phosphate, gh, kh, iron, potassium, notes) VALUES "; $sql .= " ('', '$userid', '$date', '$temperature', '$ph', '$ammonia', '$nitrite', '$nitrate', '$phosphate', '$gh', '$kh', '$iron', '$potassium', '$notes') "; // #execute SQL statement $result = mysql_query($sql); // # check for error if (mysql_error()) { print "Database ERROR: " . mysql_error(); } print "<h3><font color=red>New Water Parameters Were Added</font></h3>"; } ?> The script below used to work fine but the HTTP_REFERER was unreliable so i added a re-direct if the HTTP_REFERER was unavailable and now nothing is being added to the MySQL BD, the script runs ok ie it sends the user back to where they come from, any ideas what could be wrong? <?php require("../include/mysqldb.php"); $uinwish = $_GET['uinwish']; $wishrefer = $_SERVER['HTTP_REFERER']; $wishdate = mktime(0, 0, 0, date("m"), date("d")+3, date("Y")); $rand_wish_cookie = $_COOKIE["wishtracking"]; $con = mysql_connect("$dbhost","$dbuser","$dbpass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$dbame", $con); //DB Stuff start code below //check if the uin and cookie have already been stored together. $sql = "select * from Wish_list_guest where usercookie='$rand_wish_cookie' and uinwish='$uinwish'"; $result = mysql_query($sql); $row = mysql_fetch_row($result); if (mysql_num_rows($result)!= 1) { $issetvar = "1"; if (!isset ($wishrefer)){ $host = $_SERVER['HTTP_HOST']; $extra = 'profile.php?uin='; header("Location: http://$host/$extra$uinwish"); exit; } if (isset ($wishrefer)){ header("Location: $wishrefer"); exit; } } if ($issetvar = 1) { mysql_query("INSERT INTO Wish_list_guest (usercookie, date_delete, uinwish, referwish) VALUES ('$rand_wish_cookie', '$wishdate', '$uinwish', '$wishrefer')"); mysql_close($con); if (!isset ($wishrefer)){ $host = $_SERVER['HTTP_HOST']; $extra = 'profile.php?uin='; header("Location: http://$host/$extra$uinwish"); exit; } if (isset ($wishrefer)){ header("Location: $wishrefer"); exit; } } ?> I'm trying to make it so i can show the friends i added, or users that added a friend <table border=2 width="250" height="125"><tr> <?php $userfinal = get_username($_SESSION['user_id']); $Members = mysql_query("SELECT * FROM friends WHERE username='$userfinal' AND friendname"); $numRowsMembers = mysql_num_rows($Members); for($count = 1; $count <= $numRowsMembers; $count++) { $name = mysql_fetch_array($Members); ?> <td width="150" height="125"> <a href="view_profile.php?username=<? echo $name['friendname']?>"><img src="<? echo $name['main_P']?>" width="100" height="100"/> <? echo $name['friendname']?></a> <? if (isset($name['date']) && (time() - $name['date'] > 300)) { echo 'offline =['; } else { echo "<font color=green>[Online Now!]</font>"; } $name['date'] = time(); // update last activity time stamp ?> </td> <? } ?> </tr></table> database id friendname username 12 kristybellexo zhshero 13 demo zhshero 14 zhshero zhshero I hope that subject made sense! I have a page where I want to generate page-specific keywords automatically. Actually I have some general keywords stored in a text file and then I add the page-specific ones after those. The problem is, however, solely caused by the keywords I pull from my text file. A "1" is added to my list of keywords. Consider a news page like so: news.php // ... <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="keywords" content="<?php require('php/generateKeywordList.php'); ?>" /> </head> // ... And then generateKeywordList.php // I have omitted the part with the page-specific keywords, because it is not what causes the problem (commented it all out) set_include_path('/mypath/'); $str = require_once('includes/websiteKeywords.txt'); echo $str; // For some reason, the number 1 is added at the end of this string websiteKeywords.txt (it doesn't matter what I put in there) Code: [Select] these, are, my, keywords, for, my, website In my meta tag, the above would be displayed as: Code: [Select] these, are, my, keywords, for, my, website1 I then tried to make a simple php page like this $keywords = require('includes/websiteKeywords.txt'); echo $keywords; ... and it worked. At the moment I have absolutely no idea where the number 1 comes from. So, basically if I include the keywords directly from the text file into my meta tag, it displays fine. If I make a simple php page where I echo out the keywords from the text file, it displays fine. But if I include my php script, which echos the keywords, into my meta tag, the number 1 is added at the end of the string. Am I completely missing something here or is this extremely strange? Thanks for any help! So I ran into the most bizarre problem ever on my live server. For some odd reason something, somewhere is adding an extra character after every " mark I have. Now I am using zend framework but this can not be an issue involving them since everything works perfectly on my localhost. I am using 1and1 to host my application but for the love of me I can not narrow this down any more. Ex of my problem, I type this into my text box: "This is a sentence" and it proceeds to saving this: \"This is a sentence\" Something is happening right after I submit my form because if I add the code directly in my database, it displays everything fine. Has any one ever ran into this problem before? I have a form that has this: Code: [Select] <input type="text" name="notes_date" size="10" value="<?php echo date("m/d/Y");?>" /> I enter into the database after processing the variable like this: Code: [Select] $notes_date=date ("Y-m-d H:i:s", strtotime($_POST['notes_date'])); However, it gets stored at 2012-03-15 00:00:00 How do I fix this so that the current time gets stored instead of 00:00:00? the info posts beautifully i just canst seem to get the button to auto click or submit, tried numerous ways! help Code: [Select] <?php require_once "../store/paypal/utility.php"; require_once "../store/paypal/constants.php"; $url = "https://www.".DEFAULT_ENV.".paypal.com/cgi-bin/webscr"; $postFields = "cmd=".urlencode("_notify-synch"). "&tx=".urlencode(htmlspecialchars($_GET["tx"])). "&at=".urlencode(DEFAULT_IDENTITY_TOKEN); $ppResponseAr = Utils::PPHttpPost($url, $postFields, true); if(!$ppResponseAr["status"]) { Utils::PPError($ppResponseAr["error_msg"], $ppResponseAr["error_no"]); exit; } $httpParsedResponseAr = $ppResponseAr["httpParsedResponseAr"]; // assign posted variables to local variables $item_name = $httpParsedResponseAr['item_name']; $item_number = $httpParsedResponseAr['item_number']; $receiver_email = $httpParsedResponseAr['receiver_email']; $receiver_id = $httpParsedResponseAr['receiver_id']; $quantity = $httpParsedResponseAr['quantity']; $first_name = $httpParsedResponseAr['first_name']; $last_name = $httpParsedResponseAr['last_name']; $payer_email = $httpParsedResponseAr['payer_email']; $txn_type = $httpParsedResponseAr['txn_type']; $address_street = $httpParsedResponseAr['address_street']; $address_city = $httpParsedResponseAr['address_city']; $address_state = $httpParsedResponseAr['address_state']; $address_zip = $httpParsedResponseAr['address_zip']; $item_number = $httpParsedResponseAr['item_number']; $option_name1 = $httpParsedResponseAr['option_name1']; $option_selection1 = $httpParsedResponseAr['option_selection1']; $option_name2 = $httpParsedResponseAr['option_name2']; $option_selection2 = $httpParsedResponseAr['option_selection2']; $invoice = $httpParsedResponseAr['invoice']; $custom = $httpParsedResponseAr['custom']; $payer_id =$httpParsedResponseAr['payer_id']; ?> <html lang="en"> <head> <title>Rec</title> <link REL="stylesheet" href="include/style.css" type="text/css"> <!--[if IE]> <link REL="stylesheet" href="include/styleIE.css" type="text/css"> <![endif]--> <style> #center_block {width:50%;margin:0 auto;min-width:500px;} #contents_block {text-align:center;} #header_block {white-space:nowrap;height:25px;padding:0 10px 5px;text-align:center;} #fields_block {width:100%;margin:0;padding:10px} #header_block span {margin:0 5px} #buttons_block {padding:10px 10px 5px} #buttons_block div {padding:3px} #delimiter {margin:2px} #fields_block td {padding:3px 14px} #username_block td {padding-top:13px;white-space:nowrap;} #remember_block td {padding-bottom:13px;white-space:nowrap;} #required_block {text-align:left;padding:5px} </style> <!--[if IE]> <style> #main_block {width:100%} </style> <![endif]--> </head> <body> <script language="JavaScript" src="include/jquery.js"></script> <script language="JavaScript" src="include/jsfunctions.js"></script> <script language="JavaScript" src="include/runnerJS/RunnerBase.js"></script> <form action="rec.php" method="post" id="rec" name="rec.php"> <table id="center_block" align="center"> <tr><td id="contents_block"> <div class="main_table_border2 loginshade" id="main_block"> <table cellpadding=0 cellspacing=0 border=0 id="fields_block" class="loginshade"> <tr id="email_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_email_1">Email:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_email_0" style="white-space: nowrap;"><input id="value_email_1" style="" type="text" name="value_email_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["payer_email"]) ?>"> <font color="red">*</font></span> <div class="error"></div> </td> </tr> <tr id="pass_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_pass_1">Pass:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_pass_0" style=""><input style="" id="value_pass_1" type="Password" name="value_pass_1" maxlength=50 value="1234"> <font color="red">*</font></span> <div class="error"></div> </td> </tr> <tr id="confirm_block"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_confirm_1">Re-enter password:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_confirm_0" style=""><input style="" id="value_confirm_1" type="Password" name="value_confirm_1" value="1234"> <font color="red">*</font></span> <div class="error"></div> </td> </tr> <tr id="fname_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_fname_1">First Name:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_fname_0" style="white-space: nowrap;"><input id="value_fname_1" style="" type="text" name="value_fname_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["first_name"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="lname_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_lname_1">Last Name:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_lname_0" style="white-space: nowrap;"><input id="value_lname_1" style="" type="text" name="value_lname_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["last_name"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="address_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_address_1">Address:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_address_0" style="white-space: nowrap;"><input id="value_address_1" style="" type="text" name="value_address_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["address_street"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="city_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_city_1">City:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_city_0" style="white-space: nowrap;"><input id="value_city_1" style="" type="text" name="value_city_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["address_city"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="state_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_state_1">State:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_state_0" style="white-space: nowrap;"><input id="value_state_1" style="" type="text" name="value_state_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["address_state"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="zip_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_zip_1">Zip:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_zip_0" style="white-space: nowrap;"><input id="value_zip_1" style="" type="text" name="value_zip_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["address_zip"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="cosponsor_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_cosponsor_1">Cosponsor:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_cosponsor_0" style=""><input id="type_cosponsor_1" type="hidden" name="type_cosponsor_1" value="checkbox"><input id="value_cosponsor_1" type="Checkbox" name="value_cosponsor_1" ></span> </td> </tr> <tr id="recipients_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_recipients_1">Recipients:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_recipients_0" style="white-space: nowrap;"><input id="value_recipients_1" style="" type="text" name="value_recipients_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["quantity"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="clients_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_clients_1">Clients:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_clients_0" style=""><input id="type_clients_1" type="hidden" name="type_clients_1" value="checkbox"><input id="value_clients_1" type="Checkbox" name="value_clients_1" ></span> </td> </tr> <tr id="space_block"></tr> </table> </div> </td></tr> </table> <input type=submit value="Submit" class=button id="saveButton1" onload="Submit"></form> </body> </html> Hi, I am frustrated with getting db to store just unique entries, b/c every time I refresh the browser, the script runs and re-inserts the SAME INSERT query (but with different primary key of course which I don't want). My ques is is there a way upon the first insertion to tell it that this will be only instance of this record entered for the specified db table. So I don't want to have to encapsulate each INSERT statement in an if block to make sure that only one record exists so now I am doing it incorrectly with exit statement. please see code below: Code: [Select] <?php $_filePath="C:\\\dir\\\email.xml"; $node=basename($_filePath); $dom=new DOMDocument(); $dom->load($node); $labelPath=array(); $connection=mysql_connect("localhost","root"); mysql_select_db("dummydpev999"); $isXdocExist=mysql_query("SELECT file_Path,file_Name FROM xdocument WHERE file_Path='$_filePath' AND file_Name='$node'"); $docId=0; if(mysql_num_rows($isXdocExist)==1) { print "Entry already exists!"; $docId=mysql_next_id("xdocument")-1; print "<br />".$docId; exit; } else { mysql_query("INSERT INTO xdocument (file_Path,file_Name) VALUES ('$_filePath','$node')"); $docId=mysql_next_id("xdocument")-1; print "<br />".$docId; } writeXMLtoDBViaDOM($dom->documentElement,$labelPath,$docId); ?> Sorry I should elaborate, I think my problem is that I have tables with foreign keys rather than all tables with just primary keys, I am unsure... Any help much appreciated. i have a log file which gets new data time by time. is there any way i can read only new added entries (block) in the file? instead of start reading file from start to the end of file. this file size will be in GBs soon. Thanks. currently i am using file() to read the file. following is the example of new added block in file.
----SMS_START----
recv_time:2014-10-09 18:32:39 Span: 1 From-Number: +1347XXXXXXX Timestamp: 14/10/09 18:32:16 96 Type: PDU SMS-SMSC-Number: +12404492163 Content: Thanks, ----SMS_END---- I am building a login script to help myself learn php. I currently have the script posting any registration form errors to the registration page. I am trying to make sure whatever the user has typed into the form will redisplay once they receive the error to prevent them from having to fill out the registration form again. I got it working, but there is an extra character "/" after what was entered by the user. Here is an example: Note: "1234" has been entered into username field on reg form. Code: [Select] <tr><td>Username: </td><td><input size="20" type="text" name="username" <?php if ($_POST){ echo "value =" . $_POST['username'] ;}?> /></td></tr> I get this output Code: [Select] 1234/ I do not know where the "/" is coming from. It should only be putting "1234" back into the username field. Any help would be great. |