Philip
Staff Alumni-
Posts
4,665 -
Joined
-
Last visited
-
Days Won
20
Everything posted by Philip
-
A quick and dirty test on my server, 100,000 tests of each: for($i=0;$i<100000;$i++) $x = str_replace(' x ','', $string); And for($i=0;$i<100000;$i++) $x = preg_replace('~ x ~','', $string); Showed 0.157774925232 seconds and 0.217579841614 seconds, respectively. Tried about 10 times, about the same results each time.
-
I think someone (*caugh*Maq*cough*) is just jealous they aren't a top 10 poster. As the others said, it's better to use str_replace, it's going to be a bit faster since it doesnt have to parse the regex
-
I'm going to guess and say you want the w3 validators? I use the web developer add-on for firefox that allows for "local css/html validation" https://addons.mozilla.org/en-US/firefox/addon/60
-
It is not possible to get the mac address.
-
No matter what the OP does there will be a work around, as with well, pretty much everything in the programming world it seems. Cookies - you can clear them Sessions - destroyed when the browser closes IP - Dynamic IPs etc
-
You can use cookies
-
from is a reserved keyword, you'll need to enclose it with backticks. $sql = "INSERT INTO testimonials (testimonials, from) VALUES ($testimonials, $from)"; should be: $sql = "INSERT INTO `testimonials` (`testimonials`, `from`) VALUES ('$testimonials', '$from')";
-
Try running your query like: SELECT `id`, `username`, COUNT(*) as count FROM `online` GROUP BY `username` <?php $result = mysql_query("SELECT `id`, `username`, COUNT(*) as count FROM `online` WHERE GROUP BY `username`")or die(mysql_error()); while($row = mysql_fetch_array($result)){ $distanceInSeconds = round(abs($row['timeout'] - time())); $distanceInMinutes = round($distanceInSeconds / 60); if ( $distanceInMinutes <= 15 ) { if ( $row['username'] == 'Guest' ) { echo '<li class="link"><a href="#">Guest ('.$row['count'].')</a></li>'; } if ( $row['username'] != 'Guest' ) { echo '<li class="link"><a href="?page=profile&id=' . $row['id'] . '">' . $row['username'] . '</a></li>'; } } } ?> Also, I would consider checking the time in the query instead outside in PHP. You'll get less results and won't have to check them all for times, which result in a faster operation
-
Change: echo "did not INSERT"; to: echo "did not INSERT", mysql_error();
-
[SOLVED] Setting a max execution time for a script.
Philip replied to Niccaman's topic in PHP Coding Help
That sounds like its pretty server intensive. May I ask why you want to do that? -
echo date('n/j/Y', strtotime('2009-02-25 00:29:55'));
-
Offtopic: Isn't it against ICANN rules to do that though? I thought it was against the rules to hold a domain to resell at a higher value. I know people do it all the time, but I thought I read somewhere it was a no-no. (Found it: here - but it is only against trademarks and such) I think: dontationcrew.com
-
Adding variables to $_SESSION variables with FOR
Philip replied to Fabis94's topic in PHP Coding Help
Did you try: foreach($hparts as $key=>$value) { $_SESSION[$key] = $value; } <?php session_start(); $username = $_POST["username"]; $hiscores = file_get_contents('http://hiscore.runescape.com/index_lite.ws?player=' . $username); $hparts = explode(',', $hiscores); // Max $hparts should be 82 (0 is first) foreach($hparts as $key=>$value) { $_SESSION[$key] = $value; } echo $_SESSION[1]; echo '<script type="text/javascript">'; echo 'window.location="hiscores_out.php";'; echo '</script>'; ?> -
PHP Help -- Running other php scripts with variables
Philip replied to bgeorge82's topic in PHP Coding Help
You can pass them as arguments in the PHP file. Here's a good example: http://web.jaypedia.com/web/cron/how-to-pass-php-cron-job-parameters-arguments-or-variables.htm -
Adding variables to $_SESSION variables with FOR
Philip replied to Fabis94's topic in PHP Coding Help
//... session start at top foreach($hparts as $key=>$value) { $_SESSION[$key] = $value; } print_r($_SESSION); // just to print what was placed in session -
Hmm... Try: $net = $facebook->api_client->fql_query("SELECT affiliations FROM user WHERE uid ='$id' "); $network = array(); $network = $net[0]['affiliations']; foreach($network as $info){
-
Or... dirname(__FILE__);
-
Have you thought about using SimpleXML - good for smaller files Otherwise... take a look at http://www.codehelp.co.uk/php/xmlparse1.php
-
Well, if it is redirecting it means: if(siteStat() == "Basketball" && $basketReg == 0) is failing A few things I would do. Check to see if those variables are coming out to what they should - if not (which they aren't) find the source. Also, add in error_reporting(E_ALL); to the top of the script to see if something is causing a warning/error.
-
Are you using the variable $network anywhere else in the script?
-
Can you print out and call variables from foreach?
Philip replied to Kane250's topic in PHP Coding Help
$contentmarker = array('$para1exploded', '$para2exploded', '$para3exploded', '$para4exploded'); Single quotes do not execute variables and such. $contentmarker = array($para1exploded, $para2exploded, $para3exploded, $para4exploded); or $contentmarker = array("$para1exploded", "$para2exploded", "$para3exploded", "$para4exploded"); -
It most likely means you're missing a } before the end of your script. Proper indenting would make it easier to spot this
-
Yeah, well it really won't do anything except take an hour away from me being on the computer. I understand the seriousness of the situation, but what's the point of me thinking about this? What can I do? I'm not an engineer. Turn off stuff you don't need, open a window from time to time instead of running the AC, blah blah blah
-
Well, it fixed your PHP error - now we have to look at your MySQL error. After this line: $sql .= ") GROUP BY title, summary, uploadBy ORDER BY occurrences DESC"; put: echo $sql; and copy/paste what you see.
-
Missing a semicolon on that first line