Jump to content

cyberRobot

Moderators
  • Posts

    3,145
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by cyberRobot

  1. Instead or running all those str_replace() function. You could do the same thing with one preg_replace() function. For more information on regular expressions and the function, visit http://php.net/manual/en/function.preg-replace.php
  2. The code works fine for me, here is part of the output: Line of text: svchost.exe C:\windows\system32\svchost.exe Type: string Find: C:\ Position: 29 Speciale zoekfunctie: C:\windows\system32\svchost.exe -------------------------------------------------------------------------------- Line of text: AtService.exe c:\Program Files\Fingerprint Sensor\AtService.exe Type: string Find: C:\ Position: Speciale zoekfunctie: c:\Program Files\Fingerprint Sensor\AtService.exe -------------------------------------------------------------------------------- Line of text: svchost.exe C:\windows\system32\svchost.exe Type: string Find: C:\ Position: 29 Speciale zoekfunctie: C:\windows\system32\svchost.exe My text file contained exactly what you mentioned in the original post. I processed the text file with your same code...except I removed the shell_exec() part and modified the fopen(). Here is the code I used: <?php $file_handle = fopen("process.txt", "r"); while(!feof($file_handle)) { $line_of_text = fgets($file_handle); $findme = "C:\\"; $pos = strrpos($line_of_text, $findme); echo("Line of text: ".$line_of_text."<br />"); echo("Type: ".gettype($line_of_text)."<br />"); echo("Find: ".$findme."<br />"); echo("Position: ".$pos."<br />"); echo("Speciale zoekfunctie: ".stristr($line_of_text, 'C:')); echo("<br /><hr />"); } fclose($file_handle); ?>
  3. Whoops, the trim() needs to go before your tests: $_POST['pseudo'] = trim($_POST['pseudo']); if (empty ($_POST['pseudo'])) { //... Sorry about the confusion.
  4. Did you try using trim()? $pseudo = mysql_real_escape_string( trim($_POST['pseudo']) ); Once you get trim() working, you shouldn't need all those str_replace() calls.
  5. Try adding quotes around the values: $sql = "INSERT INTO membres (pseudo,mdp,email) VALUES ('$trimmedpseudo','$trimmedmdp','$trimmedemail')"; Since you're assigning a string as the value, I'm pretty sure you need quotes. Of course, that should be an SQL error.
  6. It doesn't even display the "INSERT INTO membres " part? I haven't used EasyPHP before, so I'm not sure if there is a connection.
  7. According to the manual, mysql_errno() returns 0 when there is no MySQL error. http://php.net/manual/en/function.mysql-errno.php What do you get if you display the SQL query? You'll need to modify the code a bit: $sql = "INSERT INTO membres (pseudo,mdp,email) VALUES ($trimmedpseudo,$trimmedmdp,$trimmedemail)"; echo $sql; mysql_query($sql);
  8. Does it insert a blank row? If so, what happens if you do a var_dump() for the variables? http://php.net/manual/en/function.var-dump.php $pseudo = mysql_real_escape_string($_POST['pseudo']); $mdp = mysql_real_escape_string($_POST['mdp']); $email = mysql_real_escape_string($_POST['email']); var_dump($pseudo); var_dump($mdp); var_dump($email); If it you don't even get an empty row, you could see if there was a database error using mysql_error() http://php.net/manual/en/function.mysql-error.php Of course, that's assuming that you're using MySQL.
  9. You could take a look at the trim() function: http://php.net/manual/en/function.trim.php It gets rid of leading/trailing spaces. It also prevents the value from only containing spaces.
  10. For what it's worth, I prefer using SET over VALUES when using insert: $pseudo = mysql_real_escape_string($_POST['pseudo']); $mdp = mysql_real_escape_string($_POST['mdp']); $email = mysql_real_escape_string($_POST['email']); mysql_query("INSERT INTO membres SET pseudo='$pseudo', mdp='$mdp', email='$email'"); SET makes it easier to see the direct connection between the column name and it's value. Of course when you only 3 columns, it's not too difficult to see the connection.
  11. You could try: $_POST['pseudo'] = trim($_POST['pseudo']); if(isset($_POST['pseudo']) && $_POST['pseudo'] != '') { Note that the trim() function prevents spaces from being a valid value.
  12. It sounds like you're trying to save each comment in a separate text file. If that the case, is there a reason why you can't store all the comments in a single text file? With the single text file, you would just need to read in the entire file, count the number of entries as you go, and display the last line to get what you want.
  13. I prefer to know where the data comes so I've never been a fan of $_REQUEST.
  14. It looks like you're just overwriting $buffer each time, try: while (($buffer .= fgets($handle, 4096)) !== false) {
  15. If you have an iPhone, you could check out a free app called Dragon Dictation. It's by the same folks who developed Dragon NaturallySpeaking.
  16. I'm not really sure what you're looking for, but to add a comments box you could: [*]Create an HTML form with a textarea tag for the comments box and a submit button [*]When the form is submitted, you can use PHP to process the form and store the data however you want You could store the comments in a database, text file, send via e-mail...
  17. Thanks for the suggestions requinix and djlee! Given the impending deadline, I'm planning to use the foreach loops. My main concern with using the foreach loops is that my form currently has 80 checkboxes. Since most of the checkboxes fall under the same sub-section ID, the foreach loops would execute more times than necessary. But I was able to limit the number of executions by creating a seperate array to track which sub-section IDs were already changed. Thanks again!
  18. I currently have a multidimensional array that looks like: <?php //... $sectionArray = array( array( 'label' => 'Training and Education', 'subSections' => array( array( 'label' => 'All Centers:', 'id' => 'trainEdu_allCenters', 'checkFound' => false ) ) ), array( 'label' => 'Technical Assistance', 'subSections' => array( array( 'label' => 'Activities that do not require extensive technical or engineering expertise:', 'id' => 'techAssist_laymanExp', 'checkFound' => false ), array( 'label' => 'Activities that require engineering expertise:', 'id' => 'techAssist_engExp', 'checkFound' => false ) ) ), //... ?> The current setup seems to work well for displaying the list of main and sub sections. But the issue I'm having is updating the checkFound part of the array. For example, when someone fills out a form and they check one of the "techAssist_laymanExp" boxes, I want the checkFound element for that id to be set to true. Note that I know that I could use a foreach loop, but I was hoping there was an array function(s) that could help out. Something that could quickly find the id and allow me to jump to the corresponding checkFound element. For what it's worth, my checkboxes currently look like this: <input type='checkbox' name='techAssist_laymanExp22' id='techAssist_laymanExp22' /> Where "techAssist_laymanExp" comes from the array above and "22" indicates the ID of the checkbox in the database.
  19. Thanks for jumping in! I tend to forget about MySQL options.
  20. Instead of embeding the comments in the query, you could do something like: $query = "SELECT $select " . "FROM dbPosts " . //from "LEFT JOIN dbUsers " . //left join "ON dbPosts.username_id = dbUsers.id " . "LEFT JOIN dbFriends " . //left "ON (dbPosts.username_id = dbFriends.my_id)";
  21. I'm not sure what $zoneNo contains, but let say you select tag looks like this: echo "<select name='zone_id' style=\"width: 175px\">"; In the code that processes the form submission, the zone_id can be retrieved with the following variable: $_POST['zone_id']
  22. You could add PHP comments that describe the query: http://php.net/manual/en/language.basic-syntax.comments.php
  23. Have you tried using var_dump() to see if the variable contain what you think they should? http://php.net/manual/en/function.var-dump.php
  24. The notice displays for me without using ini_set(), but I suppose it depends on how the server/page is set up. Thanks for pointing that out. Of course, you'll want to use both if you're looking to hide errors on a "live" website.
  25. Do the elements need to appear on the same page or can they appear on the next page? For the same page, you'll need to use something like JavaScript. Otherwise, you could create a multi-step form using PHP.
×
×
  • 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.