Jump to content

AyKay47

Members
  • Posts

    3,281
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by AyKay47

  1. you did not wrap the index in quotes, so the parser assumes this as a constant, which it is not, try my code
  2. I assume that you have prooperly debugged your query before posting..? try this $form_name = $_POST['formName']; if(!empty($_POST['formName'])){ $form_name = mysql_real_escape_string($form_name); $query = mysql_query("UPDATE contacts SET fname = '$form_name' WHERE ID = $rec"); if(!$query){ exit(mysql_error()); }else{ print "query was a success"; } } If this does not work for you, I will need to see more of your code
  3. not sure how you are inputing the lines from fgets into the array since its not actually in your code...but here $handle = @fopen("./IPs.txt", "r"); if ($handle) { while (($buffer = fgets($handle, 4096)) !== false) { echo $buffer; $ipList[] = $buffer } if (!feof($handle)) { echo "Error: unexpected fgets() fail\n"; } fclose($handle); } print_r($ipList);
  4. Not quite (see include): Without using the output buffering (ob_start(), etc), any output of the script is sent to the browser (or stdout). However, if you use: $foo = include('myfile.php'); $foo will receive true or false (depending on the success of the include); unless the included file executes a return('some value here');; in which case the returned value is assigned to $foo. Sounds confusing, so let's show an example: incSource.php <?php print('<H1>Hello World</H1>'); return('Fooled You'); main.php ob_start(); include "incSource.php"; $content = ob_get_clean(); # $content now contains "<H1>Hello World</H1>" $message = include 'incSource.php'; # $message now contains "Fooled You" yes you're right thank you for pointing out my error...I forgot that a return needs to be used in order to get the desired results here...not realistic in this case..thanks again
  5. you can also simply set the include to a variable... $message = include 'test.php'; however I myself would prefer requinix method with output buffering
  6. why don't you echo the beginning an ending parts of the div, and make the middle dynamic <?php if (isset($_POST['message'])) { if (isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token']) { $message = htmlentities($_POST['message']); $message2 = htmlentities($_POST['message2']); $fp = fopen('messages.txt', 'a'); fwrite($fp, "<p>$message<br />$message2</p>"); fclose($fp); } } $token = md5(uniqid(rand(), true)); $_SESSION['token'] = $token; ?> <form id="contFrm" method="POST"> <input type="hidden" name="token" value="<?php echo $token;?>" /> <label><span class="required">*</span> Full Name:</label> <input type="text" class="box" name="message"><br /> <label><span class="required">*</span> Message: </label> <textarea name="message2" id="message" cols="25" rows="8"></textarea><br /> <input type="submit" class="button" value="Submit"> </form> <?php echo "<div id=\"census41_messages\"> "; readfile('messages.txt'); echo "</div>"; ?>
  7. why are you writing HTML to a text file? Without seeing your code, exactly where you are having issues, its hard to diagnose the problem(s).....
  8. knobby, I provided answers on your other thread....
  9. there are a few examples in the link that I provided
  10. can you post your table set up
  11. if you really want to use a loop, you can take what wildteen88 suggested or something like it, and incorporate the continue statement for the instances that you will not want to echo
  12. excellent, please mark this as solved....lower left hand of the thread..
  13. AyKay47

    preg_match

    well preg_match won't actually sanitize the string, depending on what you are doing with the input you will want to sanitize it..
  14. AyKay47

    preg_match

    magic_quotes is deprecated and should be turned off
  15. AyKay47

    preg_match

    it wouldn't make much sense to sanitize your value before passing it through preg_match
  16. you will want to use trim here $vars=explode(",", $list); foreach($vars as $value){ trim($value); } if(in_array($var, $vars)){//do something} this should give you the desired results
  17. there are several ways to do this, however simply echoing the array elements is the simplest and shortest method for this specific instance
  18. why can't you simply echo other keys? <?php $field_array = array( 'field1' => '<tr><td>Field 1:</td><td><input type="text" name="field1" /></td></tr>', 'field2' => '<tr><td>Field 2:</td><td><input type="text" name="field2" /></td></tr>', 'field3' => '<tr><td>Field 3:</td><td><input type="text" name="field3" /></td></tr>', 'field4' => '<tr><td>Field 4:</td><td><input type="text" name="field4" /></td></tr>', 'field5' => '<tr><td>Field 5:</td><td><input type="text" name="field5" /></td></tr>', ); ?> <?php if(isset($_GET["q"])){ ?> <form method="post" action="update.php"> <table> <?php switch ($_GET["q"]) { case "option1" : echo $field_array['field1']. "<br />"; echo $field_array['field2']; // etc....... break; case "option2" : echo $field_array['field1']; break; } ?> </table> <input type="submit"> </form> <?php } ?>
  19. Yes, a query will be executed for each iteration of the while loop that is performed
  20. AyKay47

    preg_match

    the - doesn't need to be escaped, but other than that, it should allow apostrophes preg_match("/^([a-z-\' ])+$/i", $this->input[$field]) Also, you do realize that this regex will allow names like "J- o- h-- n" right?
  21. you will want to use explode after you extract the db data.. $subject = "this,is,a,test,string" $sub_strings = explode(",",$subject); if(in_array($var,$subject)){ //do something }else{ print "$var is not in the array"; } Edit: well, he beat me to it
  22. if you are trying to update multiple rows with one query, then you will need a while loop...perhaps im not fully understanding what you are trying to accomplish here
  23. You actually can use character grouping with SQL, i'm not sure why it is not working in this case.
  24. your form needs an action attribute, so it knows where to send the date.. <form method='post' action='test.php'> then on your test.php page you will have something like this mysql_connect('host', 'user', 'pass'); //your credentials mysql_select_db('test'); //you credentials $submit_button = $_POST['npc']; if(isset($submit_button)){ //check if the submit button has been clicked $name = $_POST['name']; //you need to change your textbox name from npc $name = mysql_real_escape_string(trim($name)); //clean up the input for insertion $query = mysql_query("INSERT INTO table_name VALUES('$name')"); //place inside VALUES the values that you want to insert into your db if($query){ print "Successfully inserted"; }else{ exit(mysql_error()); } }
  25. you will probably want to store the data in a database. It would be much easier if you pasted your code to this thread please
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.