
DarkWater
Members-
Posts
6,173 -
Joined
-
Last visited
Never
Everything posted by DarkWater
-
Fatal error: Call to a member function "name" on a non-object
DarkWater replied to kts's topic in PHP Coding Help
If you're using globals, you're most likely doing it wrong. -
$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.
-
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());
-
[SOLVED] Replace PART of a piece of text
DarkWater replied to scottjcampbell's topic in PHP Coding Help
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().
-
Fatal error: Call to a member function "name" on a non-object
DarkWater replied to kts's topic in PHP Coding Help
We'd need to see your code. -
[SOLVED] How to strip the last "s" from the word Shows?
DarkWater replied to ballhogjoni's topic in PHP Coding Help
<?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; -
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.
-
[SOLVED] Use of undefined constant void - assumed 'void'
DarkWater replied to MrCreeky's topic in PHP Coding Help
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. -
[SOLVED] Use of undefined constant void - assumed 'void'
DarkWater replied to MrCreeky's topic in PHP Coding Help
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.
-
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.
-
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); ?>
-
[SOLVED] MySQL help - Date field greater than or equal to today
DarkWater replied to tqla's topic in PHP Coding Help
Check out the MySQL NOW() function to get the current time.