Jump to content

bljepp69

Members
  • Posts

    111
  • Joined

  • Last visited

    Never

Everything posted by bljepp69

  1. sorry, my mistake...change that line to: [code] $typeq = ($_POST[Type]=='Any') ? '' : "AND reqtype='{$_POST[Type]}'"; [/code]
  2. Using your code above, an encoded character in an RSS feed like & # 60; (without the spaces) would show up as the number 60 instead of the character '<'.  I'm sure that's not what you intended.  You can use html_entity_decode() and/or htmlspecialchars_decode() to handle some of the characters.  The others, I would suggest a slight modification to your code where you define the special decimal character and it's replacement.  Use arrays of the 'search for' and 'replace with' characters in the first two places of your preg_replace() statement.
  3. Try something like this: [code] <?php $ownerq = $_POST[Owner]; $statusq = $_POST[Status]; $typeq = ($_POST[Type]=='Any') : '' : "AND reqtype='{$_POST[Type]}'"; //this basically says that if $_POST[Type] is equal to the string "Any" then leave this whole thing empty, //otherwise make it equal to the string "AND reqtype='the value of $_POST[Type]'" $query = "SELECT * FROM crdmain WHERE reqowner='$ownerq' AND reqstatus='$statusq' $typeq"; //by default, the query is made using only reqowner and reqstatus, the variable $typeq comes from above, //and can modify the query ?> [/code]
  4. No.  That's the problem line.  Does $act=='register' or $act==$register maybe?
  5. you're "if" statement doesn't work.  You check for three conditions of date('G') that can't possibly be true. try: [code] if (date('w') == 5 && date('G') >= 19 && date('G') <= 21) [/code]
  6. Here's a function I've used to make the search term bold in the results: [code] <?php   function formatSearch($text,$term) {     return preg_replace("/{$term}/i",'<b>${0}</b>',$text);  //note the ${0} in the replacement term keeps the original string that matched the search term   } ?> [code] So, in your code, you might use it something like: [code] <?php $searchquery="select * from site where (name like'%$term%' or url like'%$term%' or `desc` like'%$term%') and credits > 0 and state = 'Enabled' order by credits DESC  limit $start,$resultperpage"; //echo $searchquery;   $result=mysql_query($searchquery);   if(mysql_num_rows($result)!=0){     while ($row = mysql_fetch_assoc($result)) {       echo " ".formatSearch($row['name'],$term)." <br /> ".formatSearch($row['desc'],$term)."  ";     }   } ?> [/code][/code][/code]
  7. I think the last line of your query ($sql) needs to be like this: [code] RegistrationIP='" . $userinfo['RegistrationIP'] . "'"; [/code]
  8. A properly formatted SQL query will pull all of the data and order it the way you want.  Something like: [code]SELECT * FROM posts WHERE userid='$userID' ORDER BY messageid ASC LIMIT $start,$per_page[/code] That should select only the posts by a given user, order them in ascending order of when they were put into the db, and then only pull the amount of posts you want for that page.
  9. I've noticed when parsing XML, that there are special characters not handled by the above mentioned php functions.  So, I ended up writing some code using preg_replace to handle these special characters.  I know it's not real clean, but it's easy to maintain as you find additional characters that need to be replaced in the XML feed.  Something like: [code] <?php //get $input from your XML feed $xml_char = array('/&#60;/','/&#039/'); //add encoded characters to this array //note: the above array values should be the ampersand followed by the encoded value, but the forum seems to keep converting the ampersand to it's encoded equivalent...but, you get the picture. $html_char = array("<","'"); //add corresponding decoded characters to this array $output = preg_replace($xml_char,$html_char,$input); ?> [/code]
  10. There are two excellent calendar tutorials here - [url=http://www.phpfreaks.com/tutorial_cat/29/Calendars--Date-&-Time.php]http://www.phpfreaks.com/tutorial_cat/29/Calendars--Date-&-Time.php[/url].  I know at least one of them covers the questions you are asking.
  11. If you're asking about the format of the expression for $userid, it's called a ternary operator.  Read more about it here - [url=http://www.php.net/manual/en/language.operators.comparison.php]http://www.php.net/manual/en/language.operators.comparison.php[/url]. Did you have a different question?
  12. If the string is always in that format: [code] <?php   $buffer = "United States - South Carolina - Greenville - Bellsouth.net In";   preg_match_all('/(.*)\s-\s(.*)\s-\s(.*)\s-\s(.*)/',$buffer,$matches,PREG_PATTERN_ORDER);   $state = $matches[2][0];   $city = $matches[3][0];   //use this code below to see the values and structure of the $matches array.  You could set other variables using the same format above.   echo "MATCHES:<pre>".print_r($matches,TRUE)."</pre>"; ?> [/code]
  13. Oops.  Try replacing all the outer double quotes (") with single quotes (') in the $replace array [code]   $replace=array('<b>${0}</b>>','<i>${0}</i>','<u>${0}</u>','<a href="${0}">${1}</a>','<font color="${0}">${1}</font>','<font size="${0}">${1}</font>','<a href="${0}"><img scr="${0}" alt="Posted image"></a>','<textarea readonly rows="5" cols="40">Quote:${0}</textarea>','<font color="#FFFFFF">${0}</font>','<textarea rows="5" cols="30" readonly>Code:${0}</textarea>','<p align="center">${0}</p>','<sub>${0}</sub>','<sup>${0}</sup>'); [/code]
  14. Try this slight reformat of $bb & $replace [code]   $bb=array('/\[b\](.*?)\[/b\]/','/\[i\](.*?)\[/i\]/','/\[u\](.*?)\[/u\]/','/\[url=(.*?)\](.*?)\[/url\]/','/\[color=(.*?)\](.*?)\[/color\]/','/\[size=(.*?)\](.*?)\[/size\]/','/\[img\](.*?)\[/img\]/','/\[quote\](.*?)\[/quote\]/','/\[spoiler\](.*?)\[/spoiler\]/','/\[code\](.*?)\[/code\]/','/\[center\](.*?)\[/center\]/','/\[sub\](.*?)\[/sub\]/','/\[sup\](.*?)\[/sup\]/');   $replace=array("<b>$1</b>","<i>${0}</i>","<u>${0}</u>","<a href=\"${0}\">${1}</a>","<font color=\"${0}\">${1}</font>","<font size=\"${0}\">${1}</font>","<a href=\"${0}\"><img scr=\"${0}\" alt=\"Posted image\"></a>","<textarea readonly rows=\"5\" cols=\"40\">Quote:\n${0}</textarea>","<font color=\"#FFFFFF\">${0}</font>","<textarea rows=\"5\" cols=\"30\" readonly>Code:\n${0}</textarea>","<p align=\"center\">${0}</p>","<sub>${0}</sub>","<sup>${0}</sup>"); [/code]
  15. Try setting a variable with the value of array_rand($img) and then echoing that variable.  There may be an issue with echoing array_rand($img) directly. [code] $img = glob("radom_homepage_images/*.jpg"); $the_img = array_rand($img); echo'<img alt="image" src="'.$the_img.'">'; [/code]
  16. If you can't change the time of the mySQL server, try using the CONVERT_TZ() function. CONVERT_TZ(NOW(),from_tz,to_tz)
  17. The print function IS a browser function.  You don't have any control over the page sizes, printers, orientation, etc.  That's for the user to decide.  From the browser window, basically all you can do is call the print function.  Easiest is with a print button using javascript. [code] <input type="button" name="print" value="Print this page" onClick="javascript:window.print()"> [/code]
  18. If you are wanting to do it with mySQL then your call would look something like: "SELECT * FROM table WHERE variable LIKE '%word%'" If you are wanting to search using PHP, check out the strstr() function
  19. PHP is server side.  Once it loads the page, PHP really has no way to refresh the browser page.  I don't know AJAX, but I believe you can use it to call server side functions without refreshing the browser window.  You might be able to use this to run a check every so often to see if the db has been updated and then refresh the browser window, or at least the relevant portions of the browser window.
  20. Try something like this: [code] <?php   $array1 = array('med:1','med:2','med:3','temp','start');   foreach ($array1 AS $val) {     if (preg_match('/^(med\:)/',$val)) {       //do something here     }     else {       //do something else here     }       } ?> [/code]
  21. Take a look at this tutorial [url=http://www.phpfreaks.com/tutorials/129/0.php]MySQL Full-Text Searching with PHP[/url]
  22. setcookie() defines a cookie to be sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace. If output exists prior to calling this function, setcookie() will fail and return FALSE. If setcookie() successfully runs, it will return TRUE. This does not indicate whether the user accepted the cookie. You've already started output before the call to setcookie()
  23. Check out [url=http://www.php.net/manual/en/function.file-get-contents.php]file_get_contents()[/url]
  24. Those are good headers.  The only thing I can see in the above code that wouldn't work is you missed where you escaped a " in the URL.  That would cause a parse error.  Try: [code] $headers = "FROM: activation@ausfamily.com\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: multipart/alternative;\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "Content-Transfer-Encoding: 7bit"; $headers .= "\r\n"; $to = $email; $subject = "Registered"; $body = "<html><body>hi <a href=\"www.ausfamily.com/authentication.php\">Activation</a></body></html>"; mail($to, $subject, $body, $headers); [/code]
  25. This should work to see if all characters in the field are the same: [code] <?php   $str = $_POST['num'];   $char1 = substr($str,0,1); //grabs the first character of the string   if (preg_match("/^[$char1]*$/",$str)) { //checks to see if $str begins and ends with $char1 and only contains $char1     //condition is true   } ?> [/code] Matched these test conditions - 11111,44444,aaaaa Didn't match these - 111211,444442,Aaaaaa
×
×
  • 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.