![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
Jenk
-
Posts
778 -
Joined
-
Last visited
Never
Posts posted by Jenk
-
-
the local machine, being the server.
remote machine being the user's machine.
Anyhow.. for the latter (user's machine) no.
For the local/server php_uname() may contain the info you need. -
add [code]$info = '';[/code] before your loop.
-
It's all unecessary anyway.. the OP can just [code]SELECT * FROM `table` WHERE `speed` < $x and `speed` > $y[/code] .. but no one spotted that ;)
-
change the assignment operator to .= instead of just =
-
no, only the constructor.
-
for pure semantics change your query to:
[code]<?php
$result=mysql_query("UPDATE `forum_messages` SET `hits` = `hits` + 1 WHERE `id` ='$id'");
?>[/code](also note you were missing a closing apostrophe after $id)
now check that you don't run the query twice in the process of your application logic. -
[code]<?php
foreach (array_keys($_POST) as $input_name) {
//do something with $input_name
}
?>[/code] -
[code=php:0]$explodedTextArea = explode("\n", $textArea);[/code]
ot to prevent blank lines:
[code=php:0]$exploded = preg_split("/\n+/m", $text);[/code] -
Which class are you using for $pdf?
-
yup. But if any of your objects change the static property at any stage, it will change for all objects that use it as well.
-
where is the value coming from? Are you inputting explicitly as per your example, or is the data coming from say the $_POST superglobal?
-
Depends on your classes constructor.
(below is PHP5)
[code]<?php
class Foo
{
protected static $bar;
public function __construct ($bar)
{
self::$bar = $bar;
}
}
?>[/code]
That will set the static property of the class to $bar - thus every object that utilises that static property will receive the same value.
[code]<?php
class Foo
{
protected $bar;
public function __construct ($bar)
{
$this->bar = $bar;
}
}
?>[/code]
That will set the property of the object to $bar, thus only that instance of the object will maintain the value. -
uh.. guys..
[code]<?php
$val = 1.5;
$roundedVal = ceil($val); // 2
$roundedVal = floor($val); // 1
?>[/code] -
you might have magic_quotes_runtime() on, or if you aren't passing the value directly (i.e. from a form and in a variable) you may need to strip magic_quotes_gpc()
-
[code]<?php
$var = strip_tags('<div align="center">hell</div>');
?>[/code] -
not instantly, but if you pass the data through nl2br on processing, yes it will.
-
[code]<?php
$text = "This
is
some
text";
echo nl2br($text);
?>[/code]
Will output:
[code]This<br />
is<br />
some<br />
text[/code]
:) -
Easiest way to get your head around include's is to picture them as cut-and-pastes.
page2 includes page1
it achieves exactly the same functionality as if you were to cut and paste the contents of page1 into page2. (bar open and close tags) -
don't use str_replace, use nl2br().
-
Not without accessing page1 in some form or another, no it's not.
-
[code]<?php
session_start();
$_SESSION['variable'] = 'foobar';
?>[/code]
That's all you need to start a session and to assign a session variable, php does the rest for you.
Just remember to have session_start(); at the top of every page before _any_ output is produced, and the session data, if still valid, will be accessible via $_SESSION superglobal. -
server. The userid associated with the php/apache process does not have write access to the directory you are trying to create a directory within.
-
top of the page:
[code=php:0]<?php
$start = microtime(true);[/code]
bottom of the page:
[code=php:0]$end = round(microtime(true) - $start, 3);
echo 'Query completed in ' . $end . ' seconds';[/code] -
If a user logs in as [code]' OR '' = '' --[/code] they needn't bother entering a password.
I want a friendly error, not a SQL error....
in PHP Coding Help
Posted