Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Everything posted by HuggieBear

  1. I expect this line $module = ("INSERT INTO test (`Tes_Name`, `Tes_Description`, `Use_ID`, `Sub_ID`) VALUES ($Tes_Name, $Tes_Description, $Use_ID, $Sub_ID)") is meant to be $module = mysql_query("INSERT INTO test (`Tes_Name`, `Tes_Description`, `Use_ID`, `Sub_ID`) VALUES ($Tes_Name, $Tes_Description, $Use_ID, $Sub_ID)")
  2. $_SESSION is a super global, it exists in the global namespace which means it can be accessed from anywhere inside the script, regardless of whether in a function or not.
  3. Why when this is running as a cron job are you outputting all that HTML? Also, some of those errors are relating to the file handle, so when you're debugging, it might be handy to NOT suppress the errors. Change this $fp=@fopen("active_members/".$file, 'w'); To this $fp=fopen("active_members/".$file, 'w');
  4. Try parentheses around the date range $query = "SELECT * FROM table WHERE hdt1 like '%$hdt1_search%' and hdt2 like '%$hdt2_search%' and hdt3 like '%$hdt3_search%' and dateadd like '$dateadd_search' and (dateadd >= '$start_date' AND dateadd <= '$end_date') ";
  5. Can you use code tags so that it's easier to read please
  6. Try this, I've simplified the regular expression for the purposes of the example, and I only tested it with a static array, now I've added your DB code back in, I may have made a mistake. // Get words from the database and stick them into arrays $words = mysql_query("SELECT * FROM badwords WHERE 1"); while($row = mysql_fetch_array($words)){ $badwords[] = "/" . $row['word'] . "/i"; $goodwords[] = $row['rword']; } $ad_title2 = $ad_title; $ad_body2 = $ad_body; // Replace the bad words with the good words $ad_title2 = preg_replace($badwords, $goodwords, $ad_title2, -1, $title_rep); $ad_body2 = preg_replace($badwords, $goodwords, $ad_body2, -1, $body_rep); // Echo the replacement count and the new title and body echo "Title replacements: " . $title_rep . "<br />\n"; echo "Body replacements: " . $body_rep . "<br />\n"; echo "$ad_title2<br />\n"; echo "$ad_body2<br />\n";
  7. Change your database query to select just a single random video. SELECT video_url FROM user_videos ORDER BY RAND() LIMIT 1
  8. Remove lines 37 - 42 and replace line 28 with this: if (!$qry = mysql_query("SELECT * FROM pro")){ die('error ' . mysql_error()); }
  9. You could use header() to refresh the current page with a random video from the database: <?php header('refresh: 5; url=this_page.php' ); /* Refresh browser */ ?>
  10. In PHP you could try checking $_SERVER["HTTP_USER_AGENT"] for the string, as mine shows up as this
  11. This is a PHP forum, and that isn't PHP. Those look HTML comments to aid CSS rules.
  12. Change these lines $ad_title2 = preg_replace("/([^a-z^A-Z]?)($match)([^a-z^A-Z]?)/i", "$1".$replacement."$3", $ad_title2); $ad_body2 = preg_replace("/([^a-z^A-Z]?)($match)([^a-z^A-Z]?)/i", "$1".$replacement."$3", $ad_body2); to these: $ad_title2 = preg_replace("/([^a-z^A-Z]?)($match)([^a-z^A-Z]?)/i", "$1".$replacement."$3", $ad_title2, -1, $title_rep); $ad_body2 = preg_replace("/([^a-z^A-Z]?)($match)([^a-z^A-Z]?)/i", "$1".$replacement."$3", $ad_body2, -1, $body_rep); Then $title_rep contains the replacement count from the title and $body_rep contains the body replacement count. Check out the docs for preq_replace()
  13. You need to perform a comparison in your own function. Here's my code that sorts by price ascending. <?php // Setup product array (You already have yours) $products = array( 'Bike' => array('price' => '199.99'), 'Apple' => array('price' => '0.87'), 'Car' => array('price' => '5999.00') ); // Comparison function (swap the 1 and -1 around to sort descending) function compare($x, $y){ if ( $x['price'] == $y['price'] ){ return 0; } else if ( $x['price'] < $y['price'] ){ return -1; } else { return 1; } } // Sort the products uasort($products, 'compare'); // Output the products echo '<pre>'; print_r($products); echo '</pre>'; ?>
  14. OK, there's a HTML - PDF class at phpclasses.org but it submits to existing conversion sites via Web Services I believe. Give it a whirl and let us know how you get on.
  15. The code you've provided isn't the code that's outputting that bottom list. That's coming from somewhere else in your wordpress template.
  16. Change this: if (move_uploaded_file ($_FILES['thefile']['tmp_name'],"../uploads/{$FILES['thefile']['name']}")){ to this if (move_uploaded_file ($_FILES['thefile']['tmp_name'],"../uploads/{$_FILES['thefile']['name']}")){
  17. It depends, are the two tables linked in anyway? If they are then it can be done with a simple join.
  18. After this: if(isset($_POST['submitted'])) { //Handle the form try putting this echo 'Here is some more debugging info:'; print_r($_FILES); Also, put your code in code tags, there's a button for it on the editor toolbar.
  19. If you're viewing and running on Windoze then you might want to try this, it should add the End Of Line character for that specific OS. On Windoze I believe it's "\r\n" <?php // Declare Array $tmp = array(); // Hard coded details for testing $AccountNumber = "00040"; $AccountName = "Microsoft"; // Add Account Number if ($AccountNumber == "00040") { $tmp[] = "<ACCOUNT_NO>"; $tmp[] = "Account Number is 00040"; $tmp[] = "</ACCOUNT_NO>"; } else { $tmp[] = "<ACCOUNT_NO>"; $tmp[] = "Account Number is not 00040"; $tmp[] = "</ACCOUNT_NO>"; } // Attempt to add a new line to separate sections as implode wont add additional line $tmp[] = PHP_EOL; // Add Account Name if ($AccountName == "Microsoft") { $tmp[] = "<ACCOUNT_NAME>"; $tmp[] = "Account Name is Microsoft"; $tmp[] = "</ACCOUNT_NAME>"; } else { $tmp[] = "<ACCOUNT_NAME>"; $tmp[] = "Account Name is not Microsoft"; $tmp[] = "</ACCOUNT_NAME>"; } // Write contents to a file file_put_contents('accounts.txt',implode(PHP_EOL, $tmp)); ?>
  20. OK, I've tried this and it appears to be working: <?php // Declare Array $tmp = array(); // Hard coded details for testing $AccountNumber = "00040"; $AccountName = "Microsoft"; // Add Account Number if ($AccountNumber == "00040") { $tmp[] = "<ACCOUNT_NO>"; $tmp[] = "Account Number is 00040"; $tmp[] = "</ACCOUNT_NO>"; } else { $tmp[] = "<ACCOUNT_NO>"; $tmp[] = "Account Number is not 00040"; $tmp[] = "</ACCOUNT_NO>"; } // Attempt to add a new line to separate sections as implode wont add additional line $tmp[] = "\n"; // Add Account Name if ($AccountName == "Microsoft") { $tmp[] = "<ACCOUNT_NAME>"; $tmp[] = "Account Name is Microsoft"; $tmp[] = "</ACCOUNT_NAME>"; } else { $tmp[] = "<ACCOUNT_NAME>"; $tmp[] = "Account Name is not Microsoft"; $tmp[] = "</ACCOUNT_NAME>"; } // Write contents to a file file_put_contents('accounts.txt',implode("\n",$tmp)); ?>
×
×
  • 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.