Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. You can use array_map to apply the trim function to all elements of your $data array.
  2. You need to ORDER BY the playerid and date (as shown in the sample code given) so that rows for the same player are together in the result set.
  3. Edit to your edited query: Your originally posted query was getting the homes value from the first row encountered in the table for each owner.
  4. If all you want is the maximum value for each owner, you would use MAX(homes) as mh, then GROUP BY owner. You would also ORDER BY mh DESC to get the result in the order that you want them. However, if you want the specific row holding the maximum for each owner (perhaps you want the planet name or the row id), you would need to do this - http://dev.mysql.com/doc/refman/5.5/en/example-maximum-column-group-row.html
  5. @justlukeyou, Sorry man, but given that you saw an error message in front of your face that states the line number where the output is occurring at and you cannot identify what your code is doing on that line number (an echo statement) that is causing the output, means that you are not going to be able to use code that you find or to write your own code that does anything. In order to use code you find or to write your own code, you need to be able to look at the statements in the code and know what each statement actually does AND you must also be able to see what each statement contributes toward the overall goal you are trying to achieve.
  6. The header error message tells you where the output is occurring at that is causing the problem. It's your job to find what that output is and eliminate it. If you want someone here to help do that, you would need to post the error message and the code from the start of your main file up to where that output is occurring at.
  7. I'm going to guess you have a trigger in your database that is deleting the data. You also need an exit; statement after your login check header() redirect to prevent the remainder of the code on that page from running while the browser is preforming the redirect. Edit: The current code won't stop a hacker and since the code on that page runs any time it is requested by someone who is not logged in, you could be seeing unintended operation of your code. Also, if your login check code is the same on other pages, you could be seeing untended results due to other pages being requested.
  8. See Example 1 at the php.net link that shlumph posted. The most general purpose way is to use sprintf since it separates the php syntax as much as possible from the sql syntax. It's also very similar to how you would form a query using prepared statements, so when you are ready to move onto that step, things will already look familiar.
  9. Or you can use either of the two simple methods I suggested which work even if error_reporting is off or an @ error suppressor is being used on the statement.
  10. Because your column holding the id's is - Gbk_Id
  11. I'm going to assume that you solved the php syntax error in this thread, because you started another thread for a sql syntax error you made trying to 'fix' the php error.
  12. Ummm. I just checked and final syntax in this thread is exactly what you started with yesterday in a different thread where you were getting a php syntax error due to something else in the file - http://forums.phpfreaks.com/index.php?topic=365112.msg1730837#msg1730837
  13. http://us3.php.net/manual/en/features.file-upload.errors.php
  14. If track_errors is on (edit: or you turn it on in your script), you can get the last php error in $php_errormsg Also see - error_get_last
  15. Or you can literally replace each occurrence of - {$this->master_model->users_table} with - ".$this->master_model->users_table." $this->db->select("CONCAT_WS(' ',".$this->master_model->users_table.".first_name, ".$this->master_model->users_table.".last_name) AS author", FALSE); ^^^ Compare this with what you started with.
  16. Given that the current syntax you are using is error prone (how long have you been working on this one problem), wouldn't a simplified syntax that works be preferred?
  17. Mode could be from $_GET, $_POST, $_COOKIE, or $_SESSION. Perhaps there are urls with ?mode=new on them or a post method form that has <input type='hidden' name='mode' value='new'>
  18. Why are the {object_property} a problem?
  19. Also, I edited my post above with some syntax that should work that eliminates all the concatenation that is error prone because it is difficult to see where the php syntax starts and ends where the sql syntax starts and ends (you are missing a comma that is part of the CONCAT_WS() sql syntax and missing some dots that are part of the php concatenation syntax.) It's best to have as few syntax breaks/switches as possible.
  20. I think it would help if you posted all the lines of code that are building this query (i.e. the final query you posted doesn't match the fragment you have been posting.) Edit: For the fragment you have been posting - $this->db->select("CONCAT_WS(' ',{$this->master_model->users_table}.first_name, {$this->master_model->users_table}.last_name) AS author", FALSE);
  21. Edit: In addition to what kicken and jesirose posted above ^^^ while I was typing this - A few suggestions - 1) Remove all the @ error suppressors from your code and never put any in any code you are writing. You have at least one error in your code concerning the database connection link variable that should be producing two php errors that would be pointing out the problem statement so that you could find and fix it. You should always have php's error_reporting set to E_ALL (or even better a -1) and on a development system, display_errors should be ON, on a live server display_errors should be OFF and log_errors should be ON. 2) You should not be attempting to create a database and database tables 'on the fly' as a user submits data. You should be creating the database and any tables your application needs, up front, either using an installation script or directly by using any available database management tool. The main reason is that the database user you use for an application should only have the minimum permissions necessary that the application needs, so that any security holes in your code won't permit a hacker to create, drop, or alter your tables or database. 3) You don't need all the extra code to test if a database or table exists before creating it. Just use the IF NOT EXISTS syntax in the CREATE statements. 4) Your mysqli_insert_id() statement is trying to use the mysqli (with an i) extension. All the rest of your code is using the mysql (no i) extension. You cannot mix statements from the two different extensions. Also, php is actively discouraging using the mysql (no i) extension for writing new code. You should be learning and using the mysqli (with an i) extension. 5) The place you have the mysqli_insert_id() statement, inside the CREATE TABLE query, makes no sense. In fact, there's no INSERT query anywhere in the posted code, so there is nothing for a mysqli_insert_id() statement to get the last insert id from. 6) Since the posted code doesn't show where you are inserting data to get the last insert id from and where you are trying to use that value, its not possible to directly solve your current problem.
  22. In the future, please post your code using the forum's bbcode tags (the # edit form button.) I modified your post this time.
  23. The only things I can tell from the fragments of code are - 1) You don't have a session_start() statement, so any $_SESSION variables won't exist outside of the page request they were set on. 2) If you mean that the $data array doesn't contain any data, when you use it in - $smarty->assign('row',$data);, that's because web servers are stateless and the $data array you are setting in the form code only exists on that page and for the http request for that page. 3) You should not be executing a query inside of a loop. You should get all the product id's at once (see array_keys) and form a mysql IN(id,id,id,....) term for the WHERE clause to get all the product information in one query.. You would then simply loop over the result set from that query to output the cart contents. As you are looping over the result from the query, you would get the quantity by using the current product_id from the row you are looping over as an index into the session cart array.
  24. What form? What session variables? We cannot help you with tail-end symptoms without having all the code that reproduces those symptoms. There can be a half-dozen different things your code could be doing that could cause any one symptom, but without seeing all the relevant code, it is not possible to narrow them down to the one thing that is causing the problem.
  25. ^^^ That line of code is overwriting the $project object with the name, so after that point $project->id doesn't exist.
×
×
  • 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.