Jump to content

MadTechie

Staff Alumni
  • Posts

    9,409
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MadTechie

  1. yes, just echo the html ie $sel = ($filterfield == $row['field']) "selected":""; echo "<option value=\"{$row['field']}\" $sel>".htmlspecialchars($row['field'])."</option>";
  2. if you want a detailed error report see the manual for "set_error_handler" fourth parameter (contains the line number the error was raised at, as an integer. ) you should be able to convert this to an email instead of display <?php // error handler function function myErrorHandler($errno, $errstr, $errfile, $errline) { switch ($errno) { case E_USER_ERROR: echo "<b>My ERROR</b> [$errno] $errstr<br />\n"; echo " Fatal error on line $errline in file $errfile"; echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n"; echo "Aborting...<br />\n"; exit(1); break; case E_USER_WARNING: echo "<b>My WARNING</b> [$errno] $errstr<br />\n"; break; case E_USER_NOTICE: echo "<b>My NOTICE</b> [$errno] $errstr<br />\n"; break; default: echo "Unknown error type: [$errno] $errstr<br />\n"; break; } /* Don't execute PHP internal error handler */ return true; } // set to the user defined error handler $old_error_handler = set_error_handler("myErrorHandler"); ?>
  3. Wrong... quotes are for strings, back ticks are for quoting identifiers, ie fields/ tables etc.. so samshel is correct.
  4. What i normally do, is add a field to the users table called active.. (tiny int(1)) when they login i check its set to 1, if not then tell them to activate their account. a basic how to.. create 2 fields in your user table -active (tiny int(1), default 0) -activecode (mediumint(8 ) ) on signup create a random number $activecode=rand(0,99999999); and put it in the activecode field now the activation link will be something like this:~ mydomain.com/activate.php?email=$email&activecode=$activecode <?php include "databasestuff.php"; //sanitize the gets $email = mysql_escape_string($_GET['email']); $activecode= (int)$_GET['activecode']; $sql = "update user SET active=1 WHERE activecode=$activecode AND email='$email' "; ?> EDIT:the above is noway perfect and is just a basic example
  5. when they login and you confirm their password also pull back their name.. and use the for formatting from that.. as it sounds like your using the name they entered during login.. $username = "RyAn"; $sql = "SELECT username, pwd FROM users WHERE username = '$username'"; $username = $row['username']; should be fine
  6. //get forum globals $curdir = getcwd (); //shouldn't it be chdir('../../forums/'); require_once('global.php'); //OR require_once('../../forums/global.php'); //but not both ? chdir ($curdir);
  7. is the page live (so i can look)? try this test <?php //existing code $dbh = mysql_connect('localhost', 'admin', 'password') or die("Unable to connect to MySQL"); $selected = mysql_select_db("tes",$dbh) //<--**CHANGE DATABASE NAME (from first_test) $result = mysql_query("SELECT * FROM ex_table") or die(mysql_error()); if (!$result) //<--**CHANGE TABLE NAME (from table) { echo "Database is down"; } //Add test code echo "Found: ".mysql_num_rows($result)."<br>"; while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { print_r($row); echo "<br>"; } ?>
  8. Sounds like a Job for Javascipt.. maybe echo the array to a JS script (to build the array)
  9. <?php $dir = "/testfolder/test"; //Remove the trailing / if(!file_exists($dir)) echo "Folder '$dir' doesn't exist"; echo "$dir"; SureRemoveDir($dir, true); // $dir = the target directory // $DeleteMe = if true delete also $dir, if false leave it alone function SureRemoveDir($dir, $DeleteMe) { if(!$dh = @opendir($dir)) return; while (false !== ($obj = readdir($dh))) { if($obj=='.' || $obj=='..') continue; if (!@unlink($dir.'/'.$obj)) SureRemoveDir($dir.'/'.$obj, true); } closedir($dh); if ($DeleteMe){ @rmdir($dir); } } ?>
  10. Okay i added some debugging, try this and report back any errors <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Simple Dymanic Drop Down</title> </head> <body> <?php //**(BELOW) CHANGE HOST, USERNAME AND PASSWORD $dbh = mysql_connect('localhost', 'admin', 'password') or die("Unable to connect to MySQL"); $selected = mysql_select_db("tes",$dbh) //<--**CHANGE DATABASE NAME (from first_test) $result = mysql_query("SELECT * FROM ex_table") or die(mysql_error()); if (!$result) //<--**CHANGE TABLE NAME (from table) { echo "Database is down"; } ?> <!-- OK a basic form--> <form method="post" enctype="multipart/form-data" name="myForm" target="_self"> <table border="0"> <tr> <td> <select name="list1"> <option value=''></option> <?php while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { //**(Below update ID to the UniqueID or Name ALSO update the name (these are fields)) (from ID and Name) echo "<option value='".$row['ID']."'>".$row['Name']."</option>\n"; } ?> </select> </td> </tr> </table> <input type="submit" name="Submit" value="Submit" /> </form> </body> </html>
  11. I can be a twat sometimes LOL didn't even notice he wasn't calling it from the first post
  12. remove the example from the bottom REMOVE SureRemoveDir('EmptyMe', false); SureRemoveDir('RemoveMe', true);
  13. this line Print "_root.Status=success"; looks Flash based ie _root.Status=success; , you sure that shouldn't be in the action script, as it will not do much in php, other than print to the screen, yes in flash it will change the variable.
  14. OKay read the comments.. this is an NON-AJAX version i hope it helps See comments with the ** at the start <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Simple Dymanic Drop Down</title> </head> <body> <!-- OK a basic form--> <form method="post" enctype="multipart/form-data" name="myForm" target="_self"> <table border="0"> <tr> <td> <select name="list1"> <option value=''></option> <?php //**(BELOW) CHANGE HOST, USERNAME AND PASSWORD $dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db("first_test",$dbh) //<--**CHANGE DATABASE NAME (from first_test) if (!mysql_query("SELECT * FROM table")) //<--**CHANGE TABLE NAME (from table) { echo "Database is down"; } while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { //**(Below update ID to the UniqueID or Name ALSO update the name (these are fields)) (from ID and Name) echo "<option value='".$row['ID']."'>".$row['Name']."</option>\n"; } mysql_close($dbh); ?> </select> </td> </tr> </table> <input type="submit" name="Submit" value="Submit" /> </form> </body> </html> In the Subject you asked for AJAX, which you don't need if your getting the drop down populated from the load.. if you need to add another dropdown populated depending the on the selection from the first one then you can review my first example, i'll try to help with any questions.. but i think i may write a real tutorial. when time permits
  15. 1. please use code tags 2. and "the problem" is ? more details please, i don't want to waste my time checking every line of code because you don't give the details required..
  16. This is a Javascript problem NOT a PHP one
  17. and what is a "flash message".. A) a flashing message. B) a message written in flash. C) a Banner Message! what do you have so far.
  18. i wrote a example awhile back try here
  19. try this <?php // $dir = the target directory // $DeleteMe = if true delete also $dir, if false leave it alone function SureRemoveDir($dir, $DeleteMe) { if(!$dh = @opendir($dir)) return; while (false !== ($obj = readdir($dh))) { if($obj=='.' || $obj=='..') continue; if (!@unlink($dir.'/'.$obj)) SureRemoveDir($dir.'/'.$obj, true); } closedir($dh); if ($DeleteMe){ @rmdir($dir); } } //SureRemoveDir('EmptyMe', false); //SureRemoveDir('RemoveMe', true); ?>
  20. Try this Download file attached, and put in the same folder and update your script to this <?php $myf = "filename.zip"; require_once dirname(__FILE__)."/dUnzip2.inc.php"; $zip = new dUnzip2($myf); $zip->getList(); $zip->unzipAll('/home/gsclteam/public_html/stk/temp/'); ?> i have to make my way home now, but i hope this help EDIT: wrong file.. will post correct one from home
  21. ZipArchive is an extension that comes with PHP see the manual here Muhahah touché It maybe an idea to check the zlib (http://www.zlib.net/) or even try reinstalling see here have you tried another zip file, compressed with the windows compressor (assuming your on windows) or even compress a file using zlib
  22. LOL , toshay DarkWater. Was nice to offer, you could attach to the post, click Additional Options...
  23. You sure the zip is okay ? download it an confirm (don't try the local copy you uploaded, re-download)
  24. Everyone and their dog has a Captcha..
×
×
  • 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.