Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. You should (almost) never put a query inside a loop to get a SET of related/similar records from your database. You form and execute ONE query that gets all the records you want in the order that you want them and then SIMPLY iterate over the set of data that the query returns.
  2. You would have your for(){} loop start with the highest key number and decrement it until it reaches zero.
  3. <?php $lines = array_reverse(file("news.txt",FILE_IGNORE_NEW_LINES), true); foreach($lines as $key => $line){ list($title,$long_text,$short_text,$date) = explode("|", $line); echo "<a href='read.php?a=read&id=$key'><strong>$title</strong></a> (<span class='day'>$date</span>)<br>\n"; } ?>
  4. Take a look at the 'view source' in your browser.
  5. How about a virus scanner on any of the computers involved that is causing the .csv file to be opened by the native (Excel) application every time the file shows up in the file system. I reviewed (more closely) the red/green example data you posted and the differences are EXACTLY what you would get if Excel (or similar) opened and saved the file. The only things that remained double-quoted are the data values that contain a comma separator character and the format of the date/time/missing leading zeros is something you could expect Excel to do for a date/time field.
  6. Another thought - how is the original csv being produced or viewed (just opening and saving a file in Excel without actually making any changes can cause the contents of the file to be altered), because what you see in a program like Excel for display, isn't necessarily what the csv data will be (i.e. date/time fields can be displayed as anything and quotes will only be around text fields that have data that contains separate characters.)
  7. How you are looking at or displaying the output that seems to be modified from the original? It's more likely that you have a framework/cms or program editor that is doing this when it is displayed; some cron job is parsing through every new uploaded file it finds in a folder; someone is pranking you; or you have a previously uploaded file that was in the 'incorrect' format and your newly uploaded file is failing or is failing to overwrite the 'incorrect' file for some reason. This is the first post I have ever seen where it has been suggested that move_uploaded_file isn't just calling operating system commands to move the file through the operating system to the destination. However, I have seen posts where someone had built a custom framework and the output that he was suggesting that was coming through php was actually his code pre-processing incoming form data and I have even seen a case in the SMF forum software on phpfreaks where someone posted a series of names/symbols where the number 8, in a series 6,7,8,9, was altered to be 'eight'. So, somewhere in the processing/display of this data, there is some code somewhere (I hope you are not downloading/outputting this into Excel or something) that is responsible for the symptom.
  8. If you are asking about a random salt, you would store that random salt with the resulting hash value (some of the hash functions actually produce a fixed length random salt and prepend it to the beginning of the hashed value that they produce.)
  9. Edit: see AbraCadaver's post above for the same info as here ^^^ Sorry to jump in but 'pjpeg'||'jpeg'||'jpg' and 'jpeg'|'jpg'|'png'|'gif'|'pjpeg' are valid (assuming you want to do what they are actually doing) but don't work in this code because they are logically (true/false) or'ing (in the case of the || operator) or bitwise (binary) or'ing (in the case of the | operator) the strings together and then testing if the result of the or'ed expression is not equal to the variable.
  10. Ummm. I reviewed your previous threads and short answer - you don't add columns to a DATEBASE table just because you add another contact/client/location/category of information to that table. That is spreadsheet thinking and results in horrible database designs. You add rows to a database table, one row for each piece of data.
  11. Yes, but you have nested the mysql_query() statement inside of it so you have no way to check if the query executed without any errors and you will get the same result for mysql_num_rows for a failed query and for a query that simply matched zero rows. A) You must always check if a query worked or not before you attempt to access any of the information from that query. There are very few cases where you should nest function calls like that and certainly not when an inner function call can fail due to an error. B) In the code you posted $username is not being set to any value and the SELECT query won't match anything. Did you intend to match the $myid value against an id column in the table? You are also using the non-escaped $usersub username in that same query, which will produce a query error if the username happens to contain a sql special character. You have variables in the code you posted that are not being assigned any value, that are being assigned a value but you are not being used, and exist both as an escaped and a non-escaped version. You need to go through your logic and variables and make sure your code is dong what you expect.
  12. By default, the data that file returns contains all the characters found in each line, including any new-line characters. Use the FILE_IGNORE_NEW_LINES flag to eliminate the new-line characters on the end of each line.
  13. As part of your upload error checking logic, you should test for empty $_FILES/$_POST arrays.
  14. ^^^ That's interesting, because when I tried your code, I got that same result, due to a fatal runtime error that stopped the code in the first pass through the loop. Are you developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON so that php will report and display all the errors it detects? I also got a - Notice: Undefined index: Memoria Ram error in this statement - $nombre_sql = $categorias[$referencia[0]]['nombre_sql']; that indicates that your posted $categorias['PC'] array doesn't match what your code is trying to reference. This will mean that the query in $cons will fail with an error because there is no table name in the query.
  15. I don't see anything obvious in the code you have posted concerning a problem with the $max variable. Perhaps if you posted the actual error message you are getting.
  16. ^^^ In addition to passing $id somehow, you need to validate that the current visitor is an admin and has sufficient permissions to modify the data for the member with that id value. You also need to validate and escape all the data being put into the query statement.
  17. In the code you posted above, is there anything else after that code on the page that could be clearing the session variables, because you need an exit; statement after a header() redirect to prevent the remainder of the code on the page from executing. Are you developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON so that all the php detected errors will be reported and displayed? You could have an error with the session_start() statement on either page that would prevent the session variable(s) from working.
  18. @web-developer, it's not your server where the problem is occurring at.
  19. Your posted code works correctly for me (edit due to dragon_sa's post: the () on an echo statement are optional and don't affect the operation.) Is that code part of a form? Are you overwriting the $postCounter or $_POST['postCounter'] variable somewhere else in your code? Do you have more than one form field named 'postCounter'? Just posting a few lines of your code out of context doesn't help any one to help you because it doesn't show how you are using the code or what else you might be doing in the code up to that point that could affect the value.
  20. Any chance you are using short open tags <? instead of full opening tags <?php in your class file?
  21. What is your code for the pe() function?
  22. It might be worth reading about the preserve_keys parameter of the array_reverse function.
  23. ^^^ You cannot sneak up on programming because computers only do exactly what their code and data tells them to do. To the best of your ability, you must know and list everything you want to accomplish before you write any code. Otherwise you will be spend a fortune in time going back and redoing code to match the changing requirements.
  24. Also, since you want to make a comma separated list of links, you would need to form each link inside the while(){} loop when you store each value into the $tmp[] array. The implode() after the end of the while(){} loop would just be the original code that puts the comma between the elements that are in the array.
  25. A) You apparently have output_buffering turned on or you are specifically using ob_start() in your script, and B) You cannot output a download file (or binary image data) directly on web page. The only thing that you can output on the page request that causes the download are the headers followed by the file data being downloaded.
×
×
  • 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.