Jump to content

Philip

Staff Alumni
  • Posts

    4,665
  • Joined

  • Last visited

  • Days Won

    20

Everything posted by Philip

  1. And you're the type to come back in a few years and beg to have your profile & posts deleted for looking like an idiot.
  2. I like the last set the best - some of those are trippy
  3. $hex = substr($hex, 1); That will remove the first character from the string, which is placed at the end of your while loop. So, 1e5a would become e5a after the first pass of the loop. Whenever you run the loop 4 times, you are left with an empty variable, not a variable with the value of a space character. When you had it while ($hex != ' ') it would run that loop until hex was just a ' ' which would never happen. And because it was empty, and your while loop looked for a space, when it came to the if statements, the empty $hex wasn't a character between 'a' and 'f' if (ord($char) >= ord('a') and ord($char) <= ord('f')) , and it wasn't a integer between '0' and '9'.... else if (ord($char) >= ord('0') and ord($char) <= ord('9')) so it fell back to the last else statement - return an invalid hex string. else return INVALID_HEX_STRING;
  4. I find it easier to do the following, especially when you have a lot of entries: <select name="skinstyle"> <?php $options = array( 'Default' => 0, 'Light Blue' => 1, 'Sunset' => 2, 'Beautiful Blue' => 3, ); foreach($options as $text => $value) { echo '<option value="'.$value.'"'; if($Profile['skinstyle'] == $value) echo ' selected="selected"'; echo '>'.$text.'</option>'; } ?> </select> Edit: quite similar to CV's, just with keys/values for the options.
  5. You used a double quote instead of a single quote on the first echo... <?php echo '<div id="copyright" style="position:absolute;left:55px;width:150px;height:44px;z-index:32'; if(isset($_SESSION['myusername'])) { echo 'top:628px;'; } else { echo 'top:588px;'; } echo '" align="left"> <font style="font-size:13px" color="#000000" face="Arial">Squiblo &#169; 2009</font></div>'; ?> <div id="copyright" style="position:absolute;left:55px;top:588px;width:150px;height:44px;z-index:32" align="left"> <?php if(isset($_SESSION['myusername'])) echo '<font style="font-size:13px" color="#000000" face="Arial">Squiblo &#169; 2009>'; ?> </font></div>
  6. Which, technically could be shortened even more.. it just comes down to how readable you really want it. foreach(array('age', 'gender', 'rate', 'last_login') as $k) $data[$k] = (!empty($_GET[$k])) ? $_GET[$k] : ((isset($_POST[$k])) ? $_POST[$k] : ''); // or, with variable variables. foreach(array('age', 'gender', 'rate', 'last_login') as $k) $$k = (!empty($_GET[$k])) ? $_GET[$k] : ((isset($_POST[$k])) ? $_POST[$k] : '');
  7. You're going to want to put single quotes around the values ... VALUES ('$name', '$pass', '$email', '$ip')
  8. $sql = "INSERT INTO user (username,password,email,ip) VALUES ($name, $pass, $email, $ip"); Should be $sql = "INSERT INTO user (username,password,email,ip) VALUES ($name, $pass, $email, $ip)";
  9. You cannot use like $per = 5.35% because the per cent sign is a modulus operator. $creditcardpercent = .275 *100; $balance = $order * $creditcardpercent; // or $creditcardpercent = .275; $balance = $order * ($creditcardpercent * 100);
  10. I like the Head First series - well, at least I did when I was learning ajax methods a while back. That whole series draws things out, isn't as boring as a normal programming book, which for me led to learning the material faster
  11. ccleaner has done the job for me in the past on cleaning family's/friend's computers.... you know how some people always click the banner ads because they really think they can win a free ipod with no hitches.
  12. The following works: <?php define("INVALID_HEX_STRING", " Invalid hex string", true); echo hex_to_decimal('0xff').' :: '.hexdec('0xff'); echo "<br>\n"; echo hex_to_decimal('1e5a').' :: '.hexdec('1e5a'); function hex_to_decimal ($hex) { $hex = strtolower($hex); $hex = trim($hex); if (substr($hex, 0, 2) == '0x') $hex = substr($hex, 2); $result = 0; while ($hex != '') { $char = substr($hex, 0, 1); if (ord($char) >= ord('a') and ord($char) <= ord('f')) $val = 10 + (ord($char) - ord('a')); else if (ord($char) >= ord('0') and ord($char) <= ord('9')) $val = ord($char) - ord('0'); else return INVALID_HEX_STRING; $result = ($result * 16) + $val; $hex = substr($hex, 1); } return $result; } ?> while ($hex != ' ') should have been while($hex != '') otherwise after it checks the last digit there is nothing left of the string but the loop will run until it finds a space.... which it won't thus returning INVALID HEX STRING
  13. Ummm.... that screenie doesn't have anything to do with php's config file. Just your setup on your server. Create a page with just: <?php phpinfo(); ?> and see if anything might be blocking you
  14. Ohh thanks, looks interesting
  15. Umm... that would just return true/false and wouldn't grab the letter the user wants.
  16. That is the one thing I hate the most - the little tweaks and hacks to make it look/act the exact same in all the browsers (especially when I used to work with IE6 too.) But, I think jcombs hit it, front end is that instant satisfaction that you can go to sleep at night with a smile on, where as the backend you can brag about it saying "hey look, this site has 100k users using and MY code keeps them happy" Plus I like the logic side of coding.... at my full time job I don't require that much thinking, so I enjoy challenging myself to a good in-depth project from time to time.
  17. You did it write, but seeing it in color always helps: $query = 'SELECT something FROM table WHERE var = '.$var.' AND another = 1'; Have you tried echo'ing $query to see if it's what you're looking for?
  18. Is it solved or was that a mistake?
  19. "Not working" isn't very descriptive. Are you sure the page with the validation is "contact_sucess.php"? Also, make sure to use full php tags (<?php) instead of short tags (<? ) as they are turned off by default
  20. my thoughts.
  21. That means $result isn't a valid mysql result resource, or in other words mysql_query(" SELECT games.Name2 FROM games WHERE Name2 = \"$search\" ORDER BY occurrences DESC "); failed. Place a echo mysql_error(); just after you run that query and it will you give the reason why its failing.
  22. Try running this and see what you get: mysql_select_db("comics", $con); //Delete all existing entries $delete = "DELETE FROM lookup_comics WHERE UID = '$session->username'"; mysql_query($delete); if (!mysql_query($delete,$con)) { die('Error: ' . mysql_error()); } //Insert all new entries into table $sql = "INSERT INTO lookup_comics (UID, CID) VALUES "; $comics = $_POST["comics"]; $count = 0; // for debugging foreach ($comics as $cid) { $count++; // for debugging $sql .= "('$session->username', '$cid'),"; echo "Record Added: ".$session->username.", ".$cid."<br>"; } $sql = substr($sql, 0, -1); echo $sql."<br>"; mysql_query($sql); echo 'Rows we should have: ',$count,' actual rows inserted: ',mysql_affected_rows(),' and any errors: ',mysql_error(),'<br>';
  23. Something like: <?php $error_message = array(); if(($_FILES['userfile']['size'] > $_POST['MAX_UPLOAD_SIZE']) || ($_FILES['userfile']['size'] > $max_size)) { $error_message['size'] = "Upload file size too large: (<b>{$_FILES['userfile']['size']}</b>). Must not exceed {$max_size}kb."; } $array = explode(".", $_FILES['userfile']['name']); $nr = count($array); $ext = $array[$nr-1]; // I condensed all 3 of the next if's into one... since they were checking for the same thing pretty much. if(($ext !="jpg") && ($ext !="jpeg") && ($ext !="png") && ($ext !="pjpeg") && ($_FILES['userfile']['type'] != "image/jpeg") && ($_FILES['userfile']['type'] != "image/pjpeg") && ($_FILES['userfile']['type'] != "image/png") && ($info['mime'] != "image/jpeg") && ($info['mime'] != "image/pjpeg") && ($info['mime'] != "image/png")) { $error_message['format'] = "Upload file type un-recognized. Only .JPG or .PNG images allowed."; } if(count($error_message)>0) { // we had errors: foreach($error_message as $message) { echo '<strong>ERROR:</strong> '.$message.'<br>'; } // die, exit, or show form again. whatever you want here. } else { // we didn't have errors, continue with uploading // ... } ?>
  24. So, this query: INSERT INTO lookup_comics (UID, CID) VALUES ('admin', '1'),('admin', '4'),('admin', '8'),('admin', '9'),('admin', '10') Is inserting something like this in the database? : 'admin' '1' 'admin' '1' 'admin' '1' 'admin' '4' 'admin' '4' 'admin' '4' 'admin' '8' 'admin' '8' 'admin' '8' 'admin' '9' 'admin' '9' 'admin' '9' 'admin' '10' 'admin' '10' 'admin' '10'
  25. Ahhh, yes, I remember seeing this on the local news a few months ago. Lives about 30 minutes away. Sucks when it rains and your car is outside though
×
×
  • 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.