Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. php has a function that executes certain commands whenever the clients disconnect, don't know if this is it, but maybe worth checking: http://php.belnet.be/manual/nl/function.connection-aborted.php
  2. hostfreak the problem surely doesn't rely in the fact he used single quotes in his query
  3. sure, [code=php:0] $query = "SELECT * FROM ....";  //COmplete this $result = mysql_query($query); while($row = mysql_fetch_assoc($result)){   if (!@$row['pd_thumbnail']) {       // display noimage.jpg   } else {       echo "<img src='".$row["pd_thumbnail"]."' />";   } } [/code]
  4. xec now your obsetly making it difficult, you need the where clausule otherwise you can not check where something is equal/duplicate [code] $query = "SELECT `username`, COUNT(`username`) AS `DuplicateEntries` FROM `users` WHERE `username`='$username'";// will possibly not work... therefore rather use: $Query = mysql_query("SELECT `username` FROM `users` WHERE `username`='$username'"); $Rows = count(mysql_fetch_array($Query)); [/code]
  5. very well noticed... [code] $string = include_once('test.php');// gives you zero, nada, .. //but $string = file_get_contents('test.php');// gives you it all.... [/code] go forth and code my padawan... :d
  6. This depends if you wish to use it into an include I'd rather use [code] echo $_SERVER['SCRIPT_FILENAME'];// returns absolute path c:\path\to\script\filename.php [/code]
  7. I normally set this into the database that the username has to be an unique value Also silentwf I do not recomment using: [code] <?php if !isset($checkUsername[... // Instead use if (!in_array($username, $checkUsername)) { ... ?> [/code]
  8. ftp what do you mean? when it is already uploaded or still has to be uploaded? When it is already uploaded you will need unlink(); to delete the file.
  9. If you wanna start creating your own cms system I suggest you first find the best information you can get on cms system's and use: http://www.mamboserver.com as a startingpoint, dig into the code, try to translate what you see and try to understand it! I did it a few times, it helped me at a few points also http://www.getvanilla.com is another nice startingpoint this is a forum however...
  10. I see your using $error_message, to make sure you can display these error's above your form, and still be able to process your script above the html-head information I use one extra variable, ofcourse I am giving you the very basic here.. [code] <?php $PreCheckComplete=0; if (@$_POST) {    $errorMessage = '';    $userName = $_POST['txtUserName'];    $password = $_POST['txtPassword'];    // first, make sure the username & password are not empty    if ($userName == '') {       $errorMessage .= "&bull; You must enter your username<br />";    }    // you can also check for string length if (strlen($userName) < 6 ) { ...    if (strip_tags($userName) != $userName) {       $errorMessage .= "&bull; You are not allowed to use html in your username.<br />";    }    if ($password == '') {       $errorMessage .= "&bull; You must enter the password.<br />";    }    if (strip_tags($password) != $password) {       $errorMessage .= "&bull; You are not allowed to use html in your password.<br />";    }    if (!$errorMessage) {// no errors found..       $PreCheckComplete = 1;// Set flag       $password = sha1($password); // don't know if sha1 is already implemented..       // check the database and see if the username and password combo do match      $sql = "SELECT user_id"      . "\n FROM tbl_user"      . "\n WHERE user_name = '$userName'"      . "\n AND user_password = '$password'"      ;      $result = dbQuery($sql);   } } ?> <!-- below the headers --> <!-- above the form --> <?php if ($PreCheckComplete==0) {//Display the form    if (@$errorMessage) {      echo $errorMessage;    } ?> <form action="" method="post" .... <?php } else { // Display success   echo 'jipii'; } ?> [/code]
  11. Well because my previous post was way to long and had way to much options, I filtered it a bit and came up with this, It still need some altering though.. but it should work [code] <?php function Upload($File, $UploadFolder='', $NewFilename='', $UploadExtFilter='', $UploadMaxSize='') { if (substr($UploadFolder, -1) != '/') { $UploadFolder .= '/'; } if (!is_dir($UploadFolder)) { // Error message comes here..., or try to create the folder } if (!is_writable($UploadFolder)) { // Error message comes here..., or make it writable } if (is_uploaded_file($File['tmp_name'])) { $Filesize = $File['size']; $Filename = $File['name']; if (!preg_match('/\\.('.$UploadExtFilter.')$/i', $Filename)) { if ($Filesize > $UploadMaxSize) { // file to big.. } if ($NewFilename) { $Filename = $NewFilename; } if (file_exists($UploadFolder . $Filename)) { // Oeps already exists... } if (move_uploaded_file($File['tmp_name'], $UploadFolder . $Filename)) { // Success return true; } else { // No success return false; } } else { // Extensions not allowed } } } if ($_POST['submit']=='Upload') { if (Upload($_FILES['uploadIt'], '/upload/', 'my_file.txt', 'bat|com|php', 8000)) { echo 'jipii'; } } ?> <form action="" method="post" enctype="multipart/form-data"> <input type="file" name="uploadIt"> <input type="submit" name="submit" value="Upload"> </form> [/code]
  12. ron, don't you mean INSERT? How can you update if the page does not already exists? Thus something like: [code] $Userid = $_SESSION['userid']; // or something.. $Url = eval("http://" . $_SERVER['HTTP_POST'] . $_SERVER['PHP_SELF']);// Does php_self also includes queries? if not add . $_SERVER['QUERY_STRING']; $Sql = "INSERT INTO `favorites` (`Url`, `User_id`) VALUES ('$Url', '$Userid');"; [/code]
  13. First of all, your not gonna start comparing me with Bill Gates ok? are you talking about one single mp3 in three parts being uploaded or a dynamic mixing panel on server-side that can be controlled by users?
  14. What you are looking for is an IDE (Integrated Development Environment) an Java IDE can be found at: http://www.eclipse.org/ , ofcourse you don't wanna start programming Java, so you will need the php module, which can be found here: http://phpeclipse.sourceforge.net/ regards, Ignace
  15. the database is your friend, just create a datbase named favorites or something and then when a user clicks the 'Add to favorites' it inserts the current page(path), his userid(need this to load it on his profile/homepage page) to the database, and on his profile page you just start rollin' it out!
  16. why the hell would you do that? saving bandwith? php can process up to 16MB of upload (is not always the occasion, so check your upload settings first), if the size matters (mostly it does) :p I suggest you use winrar or any other zipping archive, I mostly use ACE or UHARC, the last one will probably resize your 3264kb big mp3 file to 42kb..
  17. I should use the user id instead of the username, username is not really a unique value, unless you make sure that when a user registers, it can not register a duplicate username, however look out for phishing then...
  18. [code] include_once('DB.php');// This will not be in your directory, but it will be in php's [/code] for the manual I would refer you to: http://pear.php.net/
  19. I am confused.., why do you twice check if the variable is not empty? [code] if (!empty(.. if (!empty(.. // Just put it together, // Also I don't think that your arrays are gonna be parsed this way, well it didn't work for me... // So therefore its better you make sure they aren't included in the quotes // Also using your $query as an array is not a really good idea, therefore you might wanna use $select = "SELECT ..."; $from = "FROM ...";// Something in this order and later on just glue it! $sql = $select . $from . $where . $query .. $query = "cpt_listings.state = '" . $_GET[search_area] . "' AND cpt_listings.city = '" . $_GET[search_area] . "' "; // If no results turn up by this one, try OR instead of AND // Hope this helps.. [/code] But hey that are just my thoughts.. whatever floats your boat :d
  20. Well it is a notice... Not that this is the best way to resolve this problem but it works.. :d $cd1 = isset(@$_REQUEST['cd1']) ? $_REQUEST['cd1'] : ''; ... however i always just use: $cd1 = @$_REQUEST['cd1'] ? $_REQUEST['cd1'] : ''; but we are using a dynamic language, and $cd1, $cd2, .. is a real waste of time so I would suggest you use: if (@$_REQUEST) {    while (false !== (list($Key, $Value) = each($_REQUEST))) {       ${$Key} = $Value;    } } and you would still have all your desired variables ($cd1, $cd2, ..)
  21. effort? I created that word!! And I already readed that topic, check my post!! However your answer is not really on-topic, unless you mean all functions are case insensitive is the best answer you can come up with! I wanna know how I can make it case sensitive! And then why I want to redeclare them? because I use them in OO. And when I want a certain count I don't gonna declare my function as: giveMeTheTotalNumber();
  22. Hitman is right! It ain't working because single quotes will not parse variables, don't ask why! They also do not parse newlines (\n) therefore you need to use double quotes, they will do the trick... There goes my fine neat coding...
  23. Hey Problem Number 1: I happen to use sometimes the name of functions that already exists like count(), isset(), but change them into Count(), and IsSet() now when I do this I get the problem that the parser tells me that I can not redeclare these functions, does somebody know how I can make functions case sensitive, My server is running on windows, so yes that is my first problem... :d Problem Number 2: If anybody of you is experienced in security, then please feel free to share your information with me! Or even just tell me things where I need to pay attention to! Because I know that private and public just don't do the trick... P.S.: English is not my native language, but you already knew that?
  24. DROPDOWN FORM [code] $form = '<select name="option" onChange="window.location.href=\'file.php?option=\'+this.options[this.selectedIndex].value;"> <option value="0">Speed</option> <option value="1">Power</option> <option value="2">Dexterity</option> </select>'; [/code] BACK TO YOUR PHP [code] $option = trim( strip_tags( $_REQUEST['option'] )); switch( $option ){   case 0:     ....     if( $fatique < 2 ){       print( 'you do not have enough fatique to do this.' );//leave the die(); command out or use die( 'you do not..' );     }     ....   break;   case 1:     ...     power it up     ...   break;   case 2:     ...     dextergy WRAAAAWWWW     ...   break;   default:     print( $form );   break; } $rand=rand(1,7); $rand=$rand/10; $update=$speed+$rand; $update2=$fatigue-2; $sql2="UPDATE players SET speed='$update', fatigue='$update2' WHERE user='$user'"; if(mysql_query($sql2)) [/code]
  25. html has something really sweet for that called img :) if u put in this: <img src="upload8647987448.jpg" name="size1" width="32" height="32"> <img src="upload8647987448.jpg" name="size2" width="64" height="64"> <img src="upload8647987448.jpg" name="size3" width="128" height="128"> then when you right click on this photo and click save target as... the picture will be 32,32 or 64,64 or 128,128 i do not recommend to enlarge a photo from it original size through <img> how would you feel if they stretched you? (blurred?) ofcourse the smaller a large photo is resized the better it will look :)
×
×
  • 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.