Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. First stop using the mysql_* functions they are no longer supported. It is highly recommend you update your code to use MySQLi or PDO When using user data in a query you'd not use real_escape_string instead you'd use prepared statements (see pdo or mysqli docs for info).
  2. When modifying the php.ini you may need to restart your http server in order for the new settings to take affect. You should also run phpinfo() to confirm PHP is reading the php.ini you are editting and to confirm the changes you made in the php.ini has taken affect too.
  3. If it is also auto_increment then that will not work as the the new id value is generated when the record is inserted. You need to set other columns in your table to be unique too, such as the email address. When a column is set to unique mysql will check to make sure the data being entered for that column is unique. If it is not then it'll trigger the ON DUPLICATE KEY clause.
  4. That is because you only generate a new token. You fail to even check to see if the token is valid when the form is submitted. You need to re-read mac_gyver post again.
  5. There are many configuration settings which determines the maximum file size that can be uploaded. upload_max_filesize is one of them. There is also post_max_size, max_execution_time and max_input_time. This page explains the common pitfalls you may experience when uploading files. Unless you have access to the php.ini you may not be able to override these settings. You may be able to use ini_set or Apache .htaccess php_flag directives to override those settings. If your host does not allow this then will not be able to upload files larger than the limit your host current allows. NOTE: I have modified your topic title.
  6. Anything outside of the <?php ?> tags is considered output too. The error will be triggered because of the <html> before the <?php Modify your code so HTML is output after any business logic in your code.
  7. No I have only posted example code which shows how to set a matching value as selected in the dropdown menu. Do you understand what I posted?
  8. You need to apply the selected attribute to the current option if the value stored in the database matches it. Example test code <select name="option"> <?php // values in the drop down $options = array('apple', 'banana', 'orange', 'peach'); // the value stored in the database $valueInDB = 'orange'; foreach($options as $option) { // if the current option matches the value from the database apply the selected attribute $selected = $option == $valueInDB ? ' selected="selected"' : ''; echo '<option value="'.$option.'"'.$selected.'>'.$option.'</option>'; } ?> </select> NOTE when you are posting code please wrap it within tags. Also do not use CAPS this.
  9. Why have are you using PHP tags within a string? One way to read the contents of a file is to use file_get_contents, example $response->sms( file_get_conents('file.txt') );
  10. The problem is insert.php is returning multiple data types HTML and JSON. Remove this line from insert.php //Check $_POST data echo "<pre>"; print_r($_POST) ; echo "</pre>"; Now JQuery should then auto detect the JSON and parse it into an object.
  11. Yes. That path is called a relative file path. This is how you include files from other directories. Start your file paths in your HTML with a forward slash (this is know as an absolute file path) eg <link rel="stylesheet" href="/stylesheet.css" />
  12. And that is what my code does. Example output from my code <div class="tr normal ftr rd1">...</div> <div class="tr normal ftr rd2">...</div> <div class="tr normal ftr rd3">...</div> <div class="tr normal">...</div> <div class="tr normal odd">...</div> <div class="tr normal">...</div> <div class="tr normal odd">...</div> ...etc
  13. Wait... Before you said the top three rows will be rd1 for first row, rd2 for second row and rd3 for the third. Now you are saying the top three rows alternate between rd1 and rd2? Which is it?
  14. So the first three rows will have the the rdX class applied. Then the remaining rows have the odd class is applied alternatively? Using your $counter variable we can alternate the classes at the start of the loop, example (untested code) $counter = 1; while ($fetch = mysql_fetch_assoc($result)) { // common css classes for every row $class = "tr normal"; // if counter is less than or equal to 3 apply the ftr and rdX css class if($counter <= 3) { $class .= " ftr rd$counter"; } // otherwise apply the odd css class for every alternative row else if($counter % 2 != 0) { $class .= " odd"; } // apply the css class definitions echo '<div class="'.$class.'"> .... </div>'; $counter++; }
  15. This new problem you have has nothing to do with your PHP code or whether you are running the code locally The filtering is handled by the third party javascript code you are using. Maybe you have not handled it correctly? if not check for javascript errors in your browsers console (F12 > Console Tab). If there are javascript errors then start a new thread in the Javascript Forum.
  16. That error is caused due to leaving off the semi-colon at the end of line 65.
  17. Use a lightbox script? Heres one example http://lokeshdhakar.com/projects/lightbox2/
  18. Umm... Are you sure your server is configured with PHP? Are you running code in a file ending with .php extension? Can you tell use how this code is being called?
  19. No you haven't. You are getting that error because you have given the ON DUPLICATE KEY UPDATE clause an incorrect value. The value you pass it is the unique primary key that identifies the row you are going to update when a duplicate entry occurs.
  20. Your (html) code being output by your PHP code looks ok to me. The data returned by your query should be displayed in the HTML table. What are you seeing instead? Note you should stop using the mysql_ functions. These functions are deprecated meaning they are no longer supported and could be removed from future versions of PHP. You should be using MySQLi or PDO
  21. What are you seeing a blank white page? This usually indicates PHP encounted an error and has stopped the script from running. To so why you need to either enable error reporting or check your servers error logs. Try changing the first line to <?php /* enable error reporting on this page */ ini_set('display_errors', true); error_reporting(E_ALL); include'header.php'; ?> if there is a problem errors should be shown on screen.
  22. What does "doesn't work" mean? It would be helpful if you told use what it is you are trying to do.
  23. Values from input fields will only be sent if a form has been submitted. So you need to wrap your <select> field in a form and then submit the form using a button example <form action="add_group.php" method="get"> <!-- start form --> <select name='group' id='group' > <!-- dropdown input field --> <?php while ($line = mysql_fetch_array($result)) { echo '<option value=' . $line['ugroup'] . '>' . $line['ugroup'] . '</option>'; }?> </select> <input type="submit" value="Go" /> <!-- the submit button --> </form> Now in add_group.php you'd use $_GET['group'] to retrieve the submitted value. You can do away with submit button and submit the form by applying onchange event handler to select field.
  24. There is no need to write an entry to users.csv and then read the contents of the file filtering out the duplicates and then writing the contents back to the file. Instead. Read the contents of the file and and then only write the value in $_SERVER["HTTP_X_MXIT_USERID_R"] to the file if it does not exists $file = 'users.csv'; $mxituid = $_SERVER["HTTP_X_MXIT_USERID_R"]; // read contents of file $list = file($file, FILE_IGNORE_NEW_LINES); // if the value is not logged if(!in_array($mxituid, $list)) { // append the value to the file file_put_contents($file, $mxituid . PHP_EOL, FILE_APPEND); }
×
×
  • 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.