laffin
Members-
Posts
1,200 -
Joined
-
Last visited
Everything posted by laffin
-
Final year project, please point me in the right direction
laffin replied to oriental_express's topic in PHP Coding Help
I think so, thats how I understand it.... Complicated not at all, just follow Mchl's advice learn to work with forms. and shud be able to crank it out in a day or two -
see if ya have access exec(). if ya do than ya can pull yer cron info, using crontab.
-
Musta worked at MS for some time, ya know MS only believes in bloat bloat and more bloat....
-
why are u looping thru the records, ya shud only have 1 record with that username / password combo. change } while($row = mysql_fetch_row($result)) {[code] to this[code]} else { Everything else looks ok as coding logic goes. But, ya do have another problem with the script, that is using $_POSTs (user sent data) directly in a query. Which is a big nono. first validate than sanitize user input.
-
Remember to hit solved Congrats LiL Cruz
-
which means a stack based bbcode parser, or a preprocessor that accts for bbcode tags and identifiers. Actually i already made a stack based bbcode parser, but it has its limits as well. let me see wut i can do with unique identifiers.
-
Wut was giving by everybody is how to make a dybamic image (if its yer website). the code I posted with lil modifcation is how to make a dynamic sig image (if its on a forum ya want to use it on) since Aeon was able to post a php file as an image ya use the script i gave ya, yer image host (free webserver, no ads). and use something like [img]http://www.mywebserver.com/mysig.php[/img]
-
the php code is easy, as all it does is load up the image file and send the output. if ya have yer images as say, sig_1.gif,sig_2.gif,sig_3.gif,sig_4.gif..... we can make it really simple <?php header('Content-type: image/gif'); readfile("sig_". rand(1,4) .".gif"); ?> however this wont work in most img tags as they check the extension, ya can either use path_info or htaccess rewrite to work around it
-
time returns number of seconds a day is 24 hrs * 60 minutes * 60 seconnds which is 86400 seconds so ya can subtract the start time from end time, to get the number of seconds of its lifespan. but remember that time function 0 point is January 1 1970 00:00:00 so if ya need more than that, ya may have to use julian calander functions
-
isset does as it sounds, if the variable has been used, it's set. no matter wut the value is, null, false, "" u use it for checking the existance of the variable such as checkboxes, they dun return anything if not checked, and return value if it is checked if(isset($_POST['checkbox']) $ans='yes'; else $ans='no'; a simple way if ya doing all in one forms/php scripts, is checking $_POST. if(isset($_POST)) { // Process Form here } // Show form here empty can be null, "", false, 0, array() (empty array), or '0' we not checking existance of a variable, but checking if it has content if(empty($username)) { die('Empty username"); }
-
shud return "" empty string or null is my guess...
-
I think they use it in real world support lines already. But for opensorce, ya might have a look throught google projects or sourceforge or asembla. it really depends wut ya wanna do....
-
Than ya wud want replace nl2br to maybe something like $lines=explode("\n",$lines); $count=0; $color[0] = "#cccccc"; $color[1] = "#ffffff"; foreach($lines as $key=>$line) { $lines[$key]="<div class=\"contentalt\" style=\"background-color:{$color[$count]}\">{$line}</div>"; $count=(++$count & 1); } $lines=implode('<br>',$lines)
-
Ya may want to pick up a d&d book, or my favorite gurps. Nice thing about gurps it has two systems, basic & advanced cuz its not only weapons in calculating damage ya have any skills, armor, items that may be introduced in the advanced system it goes into body locations
-
I use a similar system, this is wut i got <?php $monsters= array( 'spirit' => 18, 'golden spirit'=>18, 'hank'=>15, 'brown fluffy'=>40, 'dralmont'=>5 ); // First add the weights $tweight=array_sum($monsters); //Create a table of roll weights $atpercent=0; foreach ($monsters as $key=>$weight) { $ptable[$key]=round(($atpercent*100),2); $atpercent+=($weight/$tweight); } // Reverse are table so the highest weights get compared first $ptable=array_reverse($ptable); // Ahhh, now ya almost get it // Now random rolls // just a sample array to hold our counters foreach ($monsters as $key=>$weight) { $rolldata[$key]=0; } $numrolls=5000; for($i=0;$i<$numrolls;$i++) { $roll=rand(0,100); foreach ($ptable as $key=>$percent) if($roll>$percent) {$rolldata[$key]++; break;} } //show stats foreach($rolldata as $key=>$data) echo $key .' = ('.$monsters[$key]/$tweight .'%) '. ($data/$numrolls)."%\r\n"; Results are predicatable according to the weights
-
if yer using php5, ya can use microtime(1) or microttime(true) this way microtime returns a float value already, so unecessary to do the explode trick to convert to a float. <?php $starttime=microtime(true); . . . echo "Page load time: ". round(microtime(true)-$startime,5); The first script excertpt ya posted just returns a unix timestamp, which is useless in a display unless ya do something with it. second one is what ya use to display the load time of a page, but note the above tip
-
i just do a google search with these terms: badwords.txt "index.of" ya shud be able to pull some good lists
-
It can be. Pagination comes in different forms from the simple Next / Prev to the complex << < 1 2 .... 634 635 > >> Jump to: just a navigation system
-
its good, but ya forget that preg_replace can take arrays for the patterns as well as the replacements so lets modify yer code to take advantage of that feature $comment = 'Dang this crap, I want to shoot somebody. But that would be dangerous!'; $wordlist = "crap:cr*p|dang:d*ng|shoot:sh**t"; $words = explode('|', $wordlist); foreach ($words as $key=>$word) { list($needle[$key],$replacement[$key])=explode(':', $word); $needle[$key]= "/\b{$needle[$key]}\b/i"; } $comment = preg_replace($needle,$replacement, $comment); echo $comment; ?> there ya have it. BTW nice work so far...
-
Ya can do it multiple ways just depends on what method ya feel more comfortable with 1) have both sites access the same db on the server 2) move message files (via ftp or some other transport 3) use html get/put (like a form, but sent to a different server) and a few other methods. The easiest will prolly be 1 hardest wud prolly be 2 3 right somewhere in the middle
-
Is there a standard max length for a username field?
laffin replied to limitphp's topic in PHP Coding Help
I'm at around 30 cheracters for my projects. but yer right most ppl choose usernames that are around 5-10 chars, and 25/30 may be excessive as well. -
Is there a standard max length for a username field?
laffin replied to limitphp's topic in PHP Coding Help
ya might have to check rfc's for max username lengthj for emails. but different systems.... use different lengths Dug this up 64 chars -
A good starting point, instead of building a forum. start with a smaller project. like a guestbook. which is basicly a single forum thread. than inch yer way adding features.
-
preg_replace is better suited for this kinda thing <?php $songs=array( array('title'=>'Song 2','artist' => 'Blur'), array('title'=>'Peter Shelter','artist' => 'Tears for fears'), array('title'=>'My Own Prison (Radio Edit)','artist' => 'Creed') ); foreach ($songs as $key=>$song) { $songs[$key]=preg_replace('/(.*)(\(.*\))/','\1',$song); } echo "<pre>\n"; print_r($songs); echo "</pre>\n";