Jump to content

jcbones

Staff Alumni
  • Posts

    2,653
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by jcbones

  1. POST is sent in the header of the requested page. Which is in the action attribute of the form. To pass the POST variables to further pages, you must set those variables into either a COOKIE, or a SESSION variable. In a nutshell, when you submit a form ( or click a link ), your computer sends a data packet to the server with the requested page's info. If you clicked on a form submit button ( with action="post" ), it will also include a POST array, containing the values of the inputs, with the input names as the KEY in the POST array.
  2. My test server is PHP 5.3.0 <?php $time = new DateTime(); for($i = 0; $i < 10; $i++) { echo $time->format('m-d-Y H:i:s') . '<br />'; $time->add(new DateInterval('P1D')); } ?> Outputs:
  3. comment out your db connection, and post some code, otherwise we are just guessing.
  4. You use javascript for that. The most popular is TinyMCE
  5. <?php $filename = 'emails.txt'; if(isset($_GET['r'])) { $file = file_get_contents($filename); $remove = strip_tags($_GET['r']); $content = str_replace($remove,'',$file); file_put_contents($filename,$content); } echo nl2br(file_get_contents($filename)); ?> <form action="" method="get"> <input type="text" name="r" value="" /> <input type="submit" name="submit" value=" Remove " /> </form> UN-Tested.
  6. Try Here
  7. str_replace() <?php $str = 'I want you to go to example@example.com'; echo str_replace('example@example.com','',$str); ?>
  8. Here is a tutorial for you to evaluate. Scraping made easy
  9. You are stripping the tags. try: <?php include "bbcode_function.php"; $var = "[b]text[/b]\n[i]me[/i]"; echo nl2br(bbcode($var)); ?>
  10. I'm not sure I understand what you are asking. I get the first two statements, but the last one kinda fogs my brain. To add an amount to a timestamp in PHP. <?php $timestamp = time(); //or you could set this to any timestamp you want to. echo date('m-d-Y h:i:sa',strtotime('+40 Minutes',$timestamp)); //gives you 40 minutes into the future. ?> To set a timestamp column in MySQL for 40 minutes into the future, you could do. <?php $sql = "UPDATE times SET timestamp_column=DATE_ADD(NOW(),INTERVAL 40 MINUTE) WHERE id='1'"; ?>
  11. Run the string through htmlentities(). This should solve your problem.
  12. if ($array['level'] == 'admin']) { //do this; } else { //do that; }
  13. AJAX is not PHP, so the data manipulation is no different than any other PHP script, it is just that the data is sent to the server via javascript. Make sure you set the POST, or GET properties in your javascript function correctly, and you should be able to retrieve those variables just like any other PHP script.
  14. replace print_r($row); With: if($row['RoundNum'] == 1) { echo '<table><tr><td>' . $row['TeamID'] . '</td><td> VS </td><td>' . $row['TeamPlayed'] . "</td></tr>\n" .'<tr><td>' . $row['ScoreA'] . '</td><td> </td><td>' . $row['ScoreB'] . "</td></tr>\n</table>"; }
  15. If it is windows, dis-regard crontab, it is not available. Set up a process running task scheduler. Task Scheduler quick reference
  16. There is not enough info for use to help you. We would need to see exactly what data you are working with. But, You could combine those queries together, with a couple of case statements. foreach($emplist as $emplists){ $sql = "SELECT SUM(CASE WHEN Status = 'Prospect' THEN 1 ELSE 0 END) as prospect, SUM(CASE WHEN Status = 'Insured' THEN 1 ELSE 0 END) AS insured FROM clients WHERE agentname = '$emplists' AND Status = 'Prospect' AND Agency = '$agency'"; $result = mysql_query($sql); if(mysql_num_rows($result) > 0) { $r = mysql_fetch_assoc($result); $prospects = $r['prospect']; $insureds = $r['insured']; } } Other than that, we are going to need to know where you get your time frame, your $emplists, and your $agency from.
  17. And if I had looked, I would have seen that. I went to the manual before commenting, just to be sure. Missed the note on the e modifier though. Never used it, but that is one worth noting. Always just used preg_replace_callback().
  18. When you destroy a session, it will still show up, UNTIL you reload the page. The reason for this, is that the script gets all of the session variables when "session_start()" is called. Use Cadaver's post to unset the variables for the page you destroyed the session on.
  19. Does this site reside on a linux server? If so, make a php file. php file <?php include('mysql_config.php'); $sql = "SELECT `hits` FROM `form_hits`"; $result = mysql_query($sql); while($r = mysql_fetch_assoc($result)) { echo $r['hits'] . "\n"; } $sql = "TRUNCATE `form_hits`"; mysql_query($sql); ?> Then insert this into your crontab. crontab MAILTO = admin@mysite.com 0 0 * * * curl --silent --compressed http://mysite.com/path/to/phpfile.php Crontab quick reference
  20. Shouldn't that be preg_replace_callback()?
  21. A very simple bbcode function. function bbcode($content) { $content = preg_replace("~\[b\](.+?)\[\/b\]~i", "<b>$1</b>", $content); $content = preg_replace("~\[i\](.+?)\[\/i\]~i", "<i>$1</i>", $content); $content = preg_replace("~\[u\](.+?)\[\/u\]~i", "<u>$1</u>", $content); $content = preg_replace("~\[img\](.+?)\[\/img\]~i", "<img src=\"$1\" alt=\"\" />", $content); $content = preg_replace("~\[url\](.+?)\[\/url\]~i", "<a href=\"$1\">[Link]</a>", $content); $content = preg_replace("~\[url=http://(.+?)\](.+?)\[\/url\]~i", "<a href=\"$1\">$2</a>", $content); $content = str_replace("\n", '<br />', $content); return($content); } It accepts the following: [url]http://google.com[/url] [url=http://google.com]Custom Text[/url] [img=http://mysite.com/images/somepic.jpg] [b]Bold[/b] [u]Underline[/u] [i]Italics[/i]
  22. Because I love the Bible, I will help you get started. Note, I only included the first 2 list, you will need to write the rest out yourself, just follow the guidelines, and make them the same as the first two. <?php //Build of the list array is: $list[ListNumber][MaxChapters] = 'Book Name'; //List1 $list[1][28] = 'Matthew'; $list[1][16] = 'Mark'; $list[1][24] = 'Luke'; $list[1][21] = 'John'; //List 2 $list[2][50] = 'Genesis'; $list[2][40] = 'Exodus'; $list[2][27] = 'Leviticus'; $list[2][36] = 'Numbers'; $list[2][34] = 'Deuteronomy'; $day = (isset($_GET['day'])) ? (int)$_GET['day'] : 1; $day_count = $day; foreach($list as $k => $v) { foreach($v as $kk => $vv) { @$count += $kk; if($day <= $count) { $todays_reading[] = $vv . ' ' . $day_count; break; } $day_count -= $kk; } $count = 0; $day_count = $day; } echo implode("<br />\n",$todays_reading); ?> <form action="" method="get"> <label for="day">Day Number</label><input type="text" name="day" value="" /></form>
  23. The line: if($name && $price && $ship && $paypal && $des && $cato_id !== ""){ do code }else{ do this } Means IF $name doesn't equal 0 or false AND $price doesn't equal 0 or false AND $ship doesn't equal 0 or false AND $paypal doesn't equal 0 or false AND $des doesn't equal 0 or false AND $cato_id doesn't equal "" THEN do code ELSE Do this You need to tell PHP EXACTLY what you are doing. Your code should probably look like: if(!empty($name) && !empty($price) && !empty($ship) && !empty($paypal) && !empty($des) && !empty($cato_id) { do code } else { do this }
  24. So, you would use part of my 3rd example. SELECT * FROM table WHERE YEAR(`date`) = '2009';
×
×
  • 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.