Jump to content

Philip

Staff Alumni
  • Posts

    4,665
  • Joined

  • Last visited

  • Days Won

    20

Everything posted by Philip

  1. Solved button is in the bottom left corner of the page, under the thread
  2. $words=(str_replace ($punc) ' ')); Isn't correct syntax. Take a look: str_replace()
  3. <?php $word1 = "php freaks"; $word2 = "phe"; echo str_replace(str_split(strtolower($word2)), '', strtolower($word1)); ?> I added strtolower to keep case out of it the mix (p != P)
  4. $original = array(1,2,3,4,5,6,7,8,9,0); $temp = array(); foreach(array_chunk($original, 4) as $k=>$v) $temp[] = implode($v); echo implode('-', $temp); Displays:
  5. Haha, I admit I did. Creepy thought that maybe one day somebody would be doing the same thing to me - and as soon as I thought that I closed the window, haha
  6. Place it right after your query.
  7. Make sure to have session_start(); at the top of both scripts. Then, setting the session: $_SESSION['last_invoice'] = mysql_insert_id();
  8. See the [tweaked] example on the page I linked to: mysql_query("INSERT INTO mytable (product) values ('kossu')"); echo "Last inserted record has id ", mysql_insert_id();
  9. I got bored, so here's whats more than likely overkill code for you (dynamically generated list with option selected): <?php // Set defaults: $min = 4; // where the select box should start $max = 6.5; // where the select box should end // Fake user input: $input = 4.14; function getData($input) { // Check for a decimal point if(!substr_count($input, '.')) { // If not, its just the feet, 0 inches $feet = $input; $inches = 0; } else { // otherwise, we need to do more checking, first we'll explode at the decimal point $temp = explode('.', $input); // Is the place past the decimal point above 11 inches (or another foot?) if($temp[1]>11) { // if yes, then we need to figure out how many extra feet it will be $feet = (int) ($temp[1]/12) + $temp[0]; // and get the remainder $inches = $temp[1]%12; } else { // Otherwise, it's okay and we'll just use what they gave us $feet = $temp[0]; $inches = $temp[1]; } } // return the items in an array return array($feet, $inches); } // Get the data prepared: $data = getData($input); $min = getData($min); $max = getData($max); // start the select box: echo '<select>'; // Start loop for feet - from min to max for($i=$min[0]; $i<=$max[0]; $i++) { // if this is the min, we should tell it where to start at for inches: if($i==$min[0]) { $j = $min[1]; } else { $j = 0; } // if this is the max, we should tell it where to end at for inches: if($i==$max[0]) { $k = $max[1]; } else { $k = 11; } // Now we need to start the inches counter: for($ii = $j; $ii<=$k; $ii++) { // Start the option, with the foot value echo '<option value="',$i; // If the inches are not 0, we should put them in the value as foot.inch if($ii != 0) { echo '.',$ii; } // Close the value quote echo '"'; // If it is the user's value, show as selected if($i==$data[0] && $ii==$data[1]) { echo ' selected="selected"'; } // Close the opening option tag and show fow many feet echo '>',$i,'ft'; // Again, if the inch value isn't 0, show it (plus in at the end) if($ii != 0) { echo ' ',$ii,'in'; } // Close option tag echo '</option>'; } } // Close select tag echo '</select>'; ?>
  10. mysql_insert_id() And unless you're getting a lot of calls per second, I wouldn't worry too much about it.
  11. oops - ignore me, misread post. sorries.
  12. I think it's okay unless your submit.php was just: <?php if(isset($_POST['foo'])) { switch($_POST['foo']) { case 'bar': $class1->submit(); break; case 'joe': $class2->submit(); break // ... } } ?> Are you using any specific pattern on your scripts?
  13. I always would get frustrated when I spent too much and it wouldn't let me spend more. I mean, I'm just following after my government, why should it stop me?
  14. JSON is normal text - just formatted for computers to read it more efficiently. Example of json: {"widget": { "debug": "on", "window": { "title": "Sample Konfabulator Widget", "name": "main_window", "width": 500, "height": 500 }, "image": { "src": "Images/Sun.png", "name": "sun1", "hOffset": 250, "vOffset": 250, "alignment": "center" }, "text": { "data": "Click Here", "size": 36, "style": "bold", "name": "text1", "hOffset": 250, "vOffset": 100, "alignment": "center", "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;" } }} You'd output it just like you would for a normal user, no content type needed.
  15. Use of global, see Toon's post.
  16. Once you have that installed properly and running, simply visit http://localhost in any browser and you should see your pages.
  17. Yeah, you can't update the same table you're selecting from in one query.
  18. Take a look at my post above - with the query. For large tables, I mean like hundreds of thousands of rows. I doubt you have that many rows in there. I have a few DB's that have over 900k rows and can still run pretty complex queries quickly. Its just a matter of testing and tweaking it.
  19. This would work, although I dunno if I'd recommend it for super large tables: SELECT clientname, sales, (SELECT count(*) + 1 FROM clients WHERE sales > c.sales) as position FROM clients as c ORDER BY sales DESC Run that in a query, and then when looping through the results it will tell you the position of each person Also, you can add in a WHERE `clientname`='NAMEHERE' to show one result, with position: SELECT clientname, sales, (SELECT count(*) + 1 FROM clients WHERE sales > c.sales) as position FROM clients as c WHERE clientname = 'bob' ORDER BY sales DESC
  20. The error message says all: With proper indention you could have seen the problem (see comment in the code): <!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=utf-8" /> <title>Register</title> </head> <?php $ipi=($_SERVER['REMOTE_ADDR']); $email=($_POST['email']); $username=($_POST['username']); //Is username longer then 3 characters? if(strlen($username)<3) { echo 'Your username must be longer than 3 characters.<br />'; } //Is there a username? else if(strlen($username)<1) { echo 'You must enter a username.<br />'; } //Is the E-Mail Valid? else if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo 'E-mail is not valid.<br />'; } //Everything looks valid now register! function reg_horn() { $s = fsockopen('hornymatches.com', 80); fwrite($s, "POST /api_join_basic.php?f_email=$email&f_username=$username&campaign_id=20928&api_username=api88&api_password=password88 HTTP/1.1 Host: hornymatches.com Connection: close; "); while(!feof($s)) { $line = fgets($s); if(stripos($line, $username) !== false) { header("location:fail.php"); } elseif(stripos($line, "OK") !== false) { header ("location:success.php"); } else { header ("location:error.php"); } break; } } // Where does this one belong to? fclose($s); } ?> <input name="f_email" type="text" value="<?php echo $email ?>" maxlength="150" /><br /> <input name="f_username" type="text" value="<?php echo $username ?>" size="15" /><br /> <input name="Submit" type="submit" onmouseup="reg_horn()" /> </form> <body> </body> </html>
  21. On one of the sites I've been developing, we used to run under the 1,000 mark, now running around 3,500 and I can tell you we're not making millions upon millions of dollars. I'm not saying we're losing money, but we're not becoming the world's next Google
  22. It's really not that bad and is quite easy after some practice. I can move this to the Regex board if you'd like. I know they are always hungry for a new challenge there.
  23. You could try adding a +, so its +size 10 that would force it to find size in its query.
  24. That will never happen as realistically, by the time IE (10?) fully supports CSS3, the others will already have already moved on to CSS 4 (or 5). True dat. Although, I will admit IE8 is doing pretty good compared to the past versions
  25. Hmm, interesting. can you echo out $query_limit_worksRS and post what it is here?
×
×
  • 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.