Jump to content

sam06

Members
  • Posts

    71
  • Joined

  • Last visited

    Never

Everything posted by sam06

  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
  14. Any ideas guys? My code: <?php mysql_connect*********************** $query = "SELECT * FROM usertable"; $result = mysql_query($query) or die(mysql_error()); $name = "Free Sweet Rewards"; $email = "samuelhale@btinternet.com"; while($row = mysql_fetch_array( $result )) { $message = "Hi there $row['username'],\nFree Sweet Rewards has recently added a load of new offers avaliable.\nThere are also a great deal of daily clicks avaliable for you to do. These clicks can mean you can order a package in just a week!\nPlease let us know what you think of the new offers!\nKind Regards,\nSam Hale - Chief Executive Officer, Ramico Media."; $to = "samuelhale@btinternet.com"; $subject = "Message from $name"; $body = "$message"; $headers = "From: $email\r\n" . "X-Mailer: php"; } ?> It's not looping yet, I just wanted to test it with my email address before sending it to the database. It's coming up with error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in email1.php on line 11 I've tried it with spaces after the \n, and without. No idea. Many Thanks, Sam
  15. Thanks very much both of you In the end I went for $check = mysql_num_rows(mysql_query("SELECT uniqueid FROM tomhar WHERE ip='$ip' ")); if( $check > 0 ) { $check5 = mysql_query("SELECT uniqueid FROM tomhar WHERE ip='$ip' "); $result = mysql_result ($check5, 0, 'uniqueid'); }
  16. Hi there- Any ideas how to remove the error? It's a query to check if the records in there. It all seems to work for me, apart from throwing up that error. Ideally I just want to stop it showing it, as it all works fine. $check = mysql_query("SELECT uniqueid FROM tomhar WHERE ip='$ip' "); if($check) { $result = mysql_result ($check, 0, 'uniqueid'); } Originally there was no IF, but I put that in to try and stop the error from coming up. Unfortunetly it didn't. The error code is saying line 19, which is the $result= line. Cheers, Sam
  17. Have done And if they lived in the UK and reg for an account, then I'll add a few points
  18. Thanks both of you, the second script was brilliant, I just added a few <BR>'s and it's brill What it looks like now: Brilliant, Thanks.
  19. Currently I am displaying sweets in my virtual shop/checkout one on top of the other, however I would like to change this to 2 or maybe 3 on a row. My code currently is: echo '<tr><td width="384" height="25" align="center">'; echo '<font color="#FFFFFF" face="Arial" size="4">'.$row['name'].'</font>'; echo '</td></tr><tr><td width="384" height="150" align="center">'; echo '<img border="0" src="'.$row['image'].'">'; echo '</td></tr><tr><td width="384" height="25" align="center">'; echo '<a href="addsweets.php?id='.$row['id'].'&user='.$username.'" class="external">Buy for '.$row['points'].' Points</a>'; echo "</td></tr>"; Is this possible? Cheers, Sam
  20. Thats brilliant, sorry for the late reply. Many thanks, Sam
  21. Simple really, but not sure how I would do it. I have a text file of numbers, seperated on a new line. I plan to move all these into a mysql database- how would I do this? I assume it would be a loop, and then the php file code would gather the line of data, to a variable. Than a mysql query would post this to the database, and this all would be looped. Any help on the php file split bit? Cheers, Sam
  22. Or maybe change this so it just displayed folders? <? /** * Change the path to your folder. * * This must be the full path from the root of your * web space. If you're not sure what it is, ask your host. * * Name this file index.php and place in the directory. */ // Define the full path to your folder from root $path = "/home/user/public/foldername/"; // Open the folder $dir_handle = @opendir($path) or die("Unable to open $path"); // Loop through the files while ($file = readdir($dir_handle)) { if($file == "." || $file == ".." || $file == "index.php" ) continue; echo "<a href=\"$file\">$file</a><br />"; } // Close closedir($dir_handle); ?>
×
×
  • 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.