taith
Members-
Posts
1,514 -
Joined
-
Last visited
Everything posted by taith
-
Getting the line number (not the ++ approach)
taith replied to ted_chou12's topic in PHP Coding Help
aah... perfect... makes sence :-D thanks! -
wait for variable change before calling function?
taith replied to ultrus's topic in PHP Coding Help
no problem... sorry... i dont know crons... cant help ya out with that... lol only problem with sleep() is that while() functions can time out... it may just cause ya some problems there... -
Getting the line number (not the ++ approach)
taith replied to ted_chou12's topic in PHP Coding Help
question on the same topic... say i have this function... [code] <? function fatal_error($string=""){ $string = 'You have an Error on line #'.__LINE__.'<br><pre>'.highlight_string($string); if(mysql_errno()!=0) $string.= '<hr>'.mysql_errno().': '.mysql_error().'<hr>'; $string .= '</pre>'; die("Fatal Error: $string"); } fatal_error(); ?> [/code] how can i get that set to 8 instead of 3? -
technically... no however... headers are always sent along whenever you click on a link... but cookies and sessions exsist only within the browser/computer... the first thing php does is grabs the headers, then it goes through the code systematically. when php comes to a cookie/session_start, it goes to the browser and grabs the requested information. now if any information has already been sent to the browser, php cant request more information and errors out. hence them errors :-)
-
[SOLVED] SESSION being set even before its called
taith replied to Nolongerused3921's topic in PHP Coding Help
welcome bottom left corner :-) -
[SOLVED] SESSION being set even before its called
taith replied to Nolongerused3921's topic in PHP Coding Help
$_SESSION[] is technically not a header. however since it is stored within the browser itself... php does grab them from the browser as tho it were a header. it does this before anything is returned to the browser, which is why session_start(); after text has been output dies immediatly. simple fix is putting session_start(); before the ob_start(); that should fix it. -
Checking for specific files via extensions in a folder
taith replied to mojito's topic in PHP Coding Help
glob() looks in the specified folder, and returns anything alikened to it... *<-- all files *.xml <-- all xml files etc... therefore... [code]$xmlfiles=glob('yourfolder/*.xml'); print_r($xmlfiles);[/code] that makes $xmlfiles an array() of all the files in that folder. [code] output array("0"=>"test.xml", "1"=>"blah.xml") [/code] -
on the page itself, set a $_SESSION[time]=time(), then on your exiting page, you just $seconds=time()-$_SESSION[time];
-
wait for variable change before calling function?
taith replied to ultrus's topic in PHP Coding Help
not that i know of... however if you set a blank page to refresh every 5-10 seconds, have your phpcode there, that'd do the job... no? -
Checking for specific files via extensions in a folder
taith replied to mojito's topic in PHP Coding Help
simplify... [code] $xmlfiles=glob('yourfolder/*.xml'); [/code] and the "if ($file != "." && $file != "..")" removes the two directories from the top... (.==self ..==parent) -
assuming you have a database... [code] <? $result=mysql_query("SELECT * FROM table"); $i=0; echo '<table>'; while($row=mysql_fetch_array($result)){ if($i==0) echo '<tr>'; echo ' <td>'.$row[row1].'</td>'; echo ' <td>'.$row[row2].'</td>'; echo ' <td>'.$row[row3].'</td>'; $i++; if($i==3){ $i=0; echo '<tr>'; } } echo '</table>'; ?> [/code] something to that effect :-)
-
whats the exact error? [code] $resultmixed = mysql_query($querymixed) or die(mysql_error()); [/code]
-
assuming your are variable based, it wouldnt matter where you include() it... if their not... you need to include() it exactly where you want the file to show.
-
[code] <a href="?file=<?=urlencode($filename)?>">Delete</a> [/code] [code] unlink(urldecode($_GET[file])); [/code]
-
that doesnt work for some isp's, this will :-) [code]<? function get_host(){ if(!$_SERVER[REMOTE_HOST]) return gethostbyaddr($_SERVER[REMOTE_ADDR]); else return $_SERVER[REMOTE_HOST]; } ?>[/code]
-
[code] <? session_start(); $password=md5($_POST[password]); $result=mysql_query("SELECT * FROM users WHERE `$username`='$_POST[username]' AND `password`='$password' LIMIT 1"); $row=mysql_fetch_array($result); if(!empty($row)){ $_SESSION[user]=$row; header();#go back to homepage }else{ header();#go back to login } unset($password); ?> [/code]
-
What's the best way to remove spaces from a string?
taith replied to MortimerJazz's topic in PHP Coding Help
no prob... trim() removes spaces from either side of a string, my str_replace() above removes all spaces from the string, wether it is at the end or between words... -
What's the best way to remove spaces from a string?
taith replied to MortimerJazz's topic in PHP Coding Help
$nospaces = str_replace(" ", "", $withspaces); -
well ya... once you get past the incompetance of javascript having something that is client side with the power of php... your limits are practically endless...
-
you'd want to use ajax for something like that...
-
no prob... just make sure on your "save" page you kill that cookie :-)
-
set a cookie on one page, and if the other page finds it... die() or whatnot...
-
no... i dont think so... you'd wanna use $_SERVER[QUERY_STRING]
-
you uset $_GET[] file.php?op=test [code] echo $_GET[op]; [/code]