Jump to content

taith

Members
  • Posts

    1,514
  • Joined

  • Last visited

Everything posted by taith

  1. not to be pushy... but wouldnt it be alot... more... robust if you cut your strings seperatly? you have to give the dimensions and the style of your cuts with that function anyways...?
  2. oooooooo... try this lol function find_differences($string1,$string2){ for($i=0; $i<=strlen($string2); $i++){ if($string1{$i}==$string2{$i}) $string3.='<span style="color:green;">'.$string2{$i}.'</span>'; else $string3.='<span style="color:red;">'.$string2{$i}.'</span>'; } return $string3; } it'll highlight the differences to the letter of what was changed...
  3. you cant refer to objects via $_POST... you'd need to have form inputs... <input type=text name=""> <input type=hidden name=""> <textarea name=""></textarea>
  4. anything is possible... and yes... it is quite easy :-) but thats relative to the programmer lol
  5. well... mysql_fetch_array(); is MUCH easier... but if you inist on doing it this way... $query = "SELECT * FROM testTableNames ORDER BY ID"; $result = mysql_query($query); ?> <table> <tr> <td>ID</td> <td>First Name</td> <td>Last Name</td> <td>City</td> <td>State</td> <td>Zip Code</td> </tr> <?php $num=mysql_num_rows($result); echo"debug num rows: $num"; $i=0; while($i < $num){ $FirstName=mysql_result($result,$i,"FirstName"); $LastName=mysql_result($result,$i,"LastName"); $Address1=mysql_result($result,$i,"Address1"); $City=mysql_result($result,$i,"City"); $State=mysql_result($result,$i,"State"); $ZipCode=mysql_result($result,$i,"ZipCode"); $ID=mysql_result($result,$i,"ID"); ?> <tr> <td><?php echo$ID ?></td> <td><?php echo$FirstName ?></td> <td><?php echo$LastName ?></td> <td><?php echo$City ?></td> <td><?php echo$State ?></td> <td><?php echo$ZipCode ?></td> </tr> <?php $i++; } ?> </table>
  6. taith

    Strlen()

    not that i know of... but there are workarounds... $int=332434; $str=$int.' '; echo strlen($str)-1; basically... your just turning it into a string for that purpose... and the space shouldnt affect any math you may need it for...
  7. how right you are... lol... i post this one here all the time... we should make a database here of these functions lol <? function filter_charlimit($string, $length="50"){ if(strlen($string)<$length) return $string; else return trim(substr($string, 0, $length)).'...'; } ?>
  8. no prob... i have yet to hacker proof that one... just to letcha know :-)
  9. ahoy! um... sorta... it searches the string for the last "." and cuts off everything before it... so... echo get_filetype('index.php'); // ouputs .php echo get_filetype('missing.html'); // ouputs .html
  10. this one is by far the best... theres nothing to mess around with... $safe=htmlentities($string, ENT_QUOTES); when you pull info out just translate it back :-)
  11. <? function get_filetype($filepath){ return strtolower(substr($filepath, strpos($filepath, strrchr($filepath, ".")))); } ?> in which wherever your trying to get the type... just... $type=get_filetype($yourfilepath);
  12. <? session_start(); header("Content-Type: image/jpeg"); create_image(); die(); function create_image(){ $pass = rand(10,99); $_SESSION["pass"] = $pass; $image = ImageCreatetruecolor(100, 20); $clr_white = ImageColorAllocate($image, 255, 255, 255); $clr_black = ImageColorAllocate($image, 0, 0, 0); imagefill($image, 0, 0, $clr_black); imagefontheight(15); imagefontwidth(15); imagestring($image, 5, 30, 3, $pass, $clr_white); imageline($image, 5, 1, 50, 20, $clr_white); imageline($image, 60, 1, 96, 20, $clr_white); imagejpeg($image); imagedestroy($image); } ?><p> </p>
  13. [_a-z0-9-] --> any letters, a-z, or numbers 0-9 (\.[_a-z0-9-]+) --> followed by a maybe a "." , and any letters/numbers @[a-z0-9-] --> an @ symbol, followed by any letters/numbers (\.[a-z0-9-]+) --> followed by maybe a ".", and any letters/numbers (\.[a-z]{2,4}) --> followed by a dot, and any letters/numbers, thats between 2-4 characters long if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $yemail)){ error("Invalid e-mail address"); } if that helps any...
  14. $hello='hia'; $var='hello'; echo $$var; //outputs hia basically, it just makes the string, the variable name :-) in that case, when you echo the $var, it makes the 'hello' into the variable, and unloads its data :-)
  15. lol... personally... i completly skip that part... lol $query=mysql_query("INSERT INTO seebergerLogin (username, password, first_name, last_name)VALUES ('$_POST[email_address]','$_POST[password]','$_POST[first_name]','$_POST[last_name]')"); thats just me tho... no point in using non changing variables only once... lol
  16. bingo... php and javascript cookies are completly interchangeable...
  17. few problems there firstly... $_POST[password] = md5($_POST[password]); # i have to go first $query="INSERT INTO seebergerLogin (username, password, first_name, last_name)VALUES ('$_POST[email_address]','$_POST[password]','$_POST[first_name]','$_POST[last_name]')"; #and you forgot to query that ;-) mysql_query($query); #also near the biginning... $check=mysql_query("SELECT username FROM seebergerLogin where username = '$_POST[email_address]' LIMIT 1") or die(mysql_error()); $row=mysql_fetch_array($check); if(!empty($row)){ . . .
  18. http://www.phpfreaks.com/forums/index.php/topic,115581.0.html
  19. http://us2.php.net/manual/en/function.file-put-contents.php the put/get :-)
  20. i agree... set the variable via a cookie... then load a php via ajax, that way php has access to your page and variables, and... you dont have to switch pages
  21. not completly true... if you switch(true){ case "$v<6": break; } it will take... basically the switch will grab the first case in which the "$v<6"===true
  22. LOL! sorry... i meant those are your options... lol require('menu.php'); --> requires menu.php to be included into the page, if its not there, ragnorak.... include('menu.php'); --> wants menu.php to be included into the page, if its not there, it shows a pretty error.... require_once('menu.php'); --> requires menu.php to be included into the page, if it hasnt been included/required before, if its not there, ragnorak.... include_once('menu.php'); --> wants menu.php to be included into the page, if it hasnt been included/required before, if its not there, it shows a pretty error....
  23. php is done executing way before your computer even touches the file(apache not withstanding)... the "only" way you can get javascript, to run a php function... is by ajax... 1 - javascript function builds ajax query 2 - ajax loads php page 3 - php returns data to ajax->javascript 4 - javascript back to html
  24. bah... too simple... i still say we should contact php mainframe programmers and have the scientific notation added as an option only... in fact... i think i will :-)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.