Jump to content

sam06

Members
  • Posts

    71
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

sam06's Achievements

Member

Member (2/5)

0

Reputation

  1. I've changed it to reverse - if theyre the same, do nothing, else this - and that works! It returns:
  2. Just changed the datatype in the DB to decimal. Now is throwing up the same error in another record! Using the brackets echo from above I now get: Postcheck: [1.99] Post: [1.99] Postcheck: [1.19] Post: [1.19] Example Item 2 Change Post to: 1.19 from 1.19 Postcheck: [1.49] Post: [1.49]
  3. Running: echo $postcheck; echo "<br>"; echo $post; echo "<br>"; before the if statement gives me: 1.89 1.89 Example Item 1 Change Post to: 1.89 from 1.89 The 1.89 and 1.89 look the same to me, so no idea why it's running the != statement...?! Should expect no output
  4. Absolutely no idea why my IF statement's playing up - needs some fresh eyes I think! if ($postcheck != $post){ if ($x == "0"){ echo $title; echo "<br>"; $x = "1"; $y = $y + 1; } echo "Change Post to: "; echo $postcheck; echo " from "; echo $post; echo "<br>"; $result2 = mysql_query("UPDATE items SET Post='$postcheck' WHERE ID='$id'") or die(mysql_error()); } When it returns $postcheck and $post, in this case, they're coming out as the same thing (on one record - no others!) - $post is retrieved from a database, and $postcheck is calculated. Both are numbers. Any ideas?!
  5. So far I've got: <?php $file=fopen("triangle.txt","r") or exit("Unable to open file!"); while (!feof($file)) { $character = fgetc($file) ; if($character != " "){ // Perform Action echo $character; // } else { echo '<br>'; } } fclose($file); ?> But that doesn't count the "new line" as a character
  6. I'm sure many of you are familiar with Project Euler - now I'm on Problem 67. I'm hoping you can help me out - I'm trying to split a txt file into parts. It's located at http://projecteuler.net/project/triangle.txt Now, I want to split it into numbers, then perform an action, and loops untill finishing. I'm not too sure how I do this - So I capture the first 2 characters, move forward 1 (does this apply when going onto a new line?), then capture the next 2 characters etc. Can anyone help me? Much appreciated, Sam
  7. Any idea why I'm getting "parse error" for this on the echo implode... line? <?php $c = 50000; $m = (int)((sqrt($c))+1); $p = array_fill(2, $c-1, 1); $i = 2; while ($i<$m) { $j=$i*2; while($j<$c+1) { $p[$j] = 0; $j += $i; } $i++; } echo implode(’ ‘,array_keys($p, 1)); ?> Many thanks. Sam
  8. Thanks a lot, I changed it a bit: $tocheck = isset($split[$count]) ? $split[$count] : ''; if($tocheck == ""){ Really appreciate it, Sam
  9. Many thanks; I'm not too sure how to emplement this though...? I've tried: <?php $input = $_POST['input']; $count = 0; $while = 0; $split = explode("\n", $input); while($while == 0) { if ( $split[$count] == "" ) { $while = 1 ; } else { // my action will go here echo $count; echo ' - '; echo $split[$count]; echo '<br>'; // $count = $count + 1; } } ?> It's working, but coming up with: Notice: Undefined offset: 2 in C:\wamp\www\splitfile.php on line 11 Any idea?
  10. Hopefully this won't take long! ; I'd like to take an input of multiple lines, split it by line, and perform an action with it. e.g. Input: 1000 1001 1002 1003 And it would do something with 1000, then 1001, then 1002 etc. Any ideas? Many thanks, Sam
  11. Very odd, but then again I've never used multiple IF statements before. This works: <?php $startingvalue = 1; while ($finished == 0){ echo $startingvalue ; if (is_int($startingvalue / 5)){ echo ' is divisible by values 1-5'; $finished = 1; } else { $startingvalue = $startingvalue + 1; echo ' is not.'; echo '<br>'; } } ?> This doesn't work: <?php $startingvalue = 1; while ($finished == 0){ echo $startingvalue ; if (is_int($startingvalue / 1)){ if (is_int($startingvalue / 2)){ if (is_int($startingvalue / 3)){ if (is_int($startingvalue / 4)){ if (is_int($startingvalue / 5)){ echo ' is divisible by values 1-5'; $finished = 1; }}}}} else { $startingvalue = $startingvalue + 1; echo ' is not.'; echo '<br>'; } } ?> Any ideas why not? Probably something very simple! Many thanks, Sam
  12. Thanks for the tip- I used $mystring = $email; $findme = '@'; $pos = strpos($mystring, $findme); Cheers
  13. Hi there again guys Is there a way to use PHP to look for an @ symbol in a field? Basically it takes a variable, if it has an @ symbol somewhere in it, do this, otherwise do that. Any ideas? Cheers, Sam
×
×
  • 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.