DarkWater
-
Posts
6,173 -
Joined
-
Last visited
Never
Posts posted by DarkWater
-
-
$qryRemHosts = sprintf("SELECT removed_hosts FROM usr_preferences WHERE uid IN('$s')", implode("', '", $uid));
Try that. Also, I don't like what you're doing with $arrLastServices. That loop seems pointless and inefficient.
-
Rather than writing your query and executing it all in one line, use a prepared statement so it can be echoed and put or die(mysql_error()) at the end of sql execution.
$sql = "SELECT email FROM `' . $table . '`"; echo $sql; mysql_query($sql) or die (mysql_error());
That's not a prepared statement, by the way; that's just using a variable...
Try something like:
$sql = "SELECT email FROM $table"; $result = mysql_query($sql) or die(mysql_error());
-
echo preg_replace('~<img src="(.+?)" />~is','[_img]$1[/_img]',$text);
There you go; that should work.
-
@sam06: Use flyhoney's method. In the one you have now, you're doing the query twice. That wastes resources and it absolutely pointless.
EDIT: Also, mysql_result() is pretty slow compared to the other fetching functions. Use one of those as opposed to mysql_result().
-
We'd need to see your code.
-
<?php $string = "Shows"; $string = rtrim($string, 's'); echo $string; ?>
If you want a more comprehensive solution that will strip ANY word of a trailing 's':
<?php $string = "Here, we have some words with letters on the end. Enjoy the shows!"; $string = preg_replace('/([a-z]+?)s(?=\s|(\b.)?$)/i', '$1', $string); echo $string;
-
Really? Just the other day you posted this question: http://www.phpfreaks.com/forums/index.php/topic,234793.msg1090660.html#msg1090660
Wouldn't think you'd be able to decrypt something. No offense. LOL.
That might have made my day.
-
I think you don't understand what a query string is. It's completely an HTTP thing and the web server handles it. When you include the file, you can simply set the variables before including and they'll be available in the included script; no need for $_GET.
-
Traditionally, 'void', when used in function headers, means that nothing gets passed in. Not sure why it says "optional" next to it on W3schools.
Regardless, the PHP manual is the best source to rely on for these function prototypes.
-
Why were you passing a string literal containing 'void' into time()?
-
You don't need regex for this.
<?php $field_name = "username_required"; if (strpos($field_name, "_required") !== FALSE) { //it's there } else { //nope }
-
mysql_real_escape_string() escape more than just quotation marks. It escapes anything that could potentially confuse MySQL and break your query.
-
Why are you looping through the table instead of just using a WHERE clause on your query?
-
Check out implode().
-
No. You're making that WAY harder than it has to be:
$mysql = "Select * from "; $mysql .= "Person "; $mysql .= "Where Name like '%$SearchA%'";
. is the concatenation operator as opposed to +. Use . where you would normally use + and you'll be fine.
-
@Maq: The string is in double quotes. It doesn't matter that the variables happen to have ' ' around them in the double-quoted string; they'll still interpolate.
-
The point of OOP is not to just simply wrap procedural code into a bunch of static functions. You might as well just have getLastUpdate(), getHosts(), etc. just as functions if that's how you're going to do it. OOP allows you to emulate real-world objects and relations and structure your code around that.
-
Wow, can we get on the subject? What websites do you recommend to monitor my sites.
http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&gfns=1&q=website+monitoring
Because THAT was hard.
-
3/5 computers in my house are on all day, every day. The other 2 are laptops, so it would be kind of dumb to leave them on. I have a backup power supply on my main box for blackouts, so it's REALLY always on.
-
Just use htmlentities().
-
Oh, got it backwards then. CV's got it.
-
This works with krsort presumably?
never mind, flipped the array around.
I used arsort(), which maintains key=>value pairs and sorts by value.
-
<?php $arr = array(999, 1000, 998); print_r(arr); arsort($arr, SORT_NUMERIC); print_r($arr); ?>
-
Check out the MySQL NOW() function to get the current time.
Fatal error: Call to a member function "name" on a non-object
in PHP Coding Help
Posted
If you're using globals, you're most likely doing it wrong.