Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. $stmt->fetch(); only fetches one row from the result set. You would need to use a loop to iterate over all the rows in the result set. The mysqli_stmt_fetch documentation contains an example that shows how you can loop over all the rows in the result set - http://us.php.net/manual/en/mysqli-stmt.fetch.php
  2. The php string you are echoing starts (and ends) with double-quotes. To close each fragment of that string to concatenate the result of php functions into it, you must use matching double-quotes. echo "a complete string fragment".date('n')."another complete string fragment".date('Y')."another complete string fragment";
  3. Because the php code is being executed inside of a html <select ></select> tag, any mysql_error output from the code will only be in the 'view source' in your browser.
  4. What URL are you using in your browser? What's the entire contents of your .php file (show the opening php tag too.)
  5. If there are zero rows matching the WHERE clause, the $totalpages/$total_pages calculation results in a zero. The code with the $current_page > $totalpages comparison last will set $current_page to zero, producing a query error because a negative value in the LIMIT is a sql error. By reversing the two comparisons, $current_page will be left as a 1, a valid page number, and the query won't fail due to a sql syntax error.
  6. The variable holding the total page count is $total_pages. You need to change all occurrences of $totalpages to $total_pages. You also need to be developing and debugging your code on a system with php's error_reporting set to E_ALL and display_errors set to ON so that php will help you by reporting and displaying all the errors it detects. You will save a ton of time.
  7. If you are using the code that Psycho posted, you will want to reverse the order of the following two lines so that if $totalpages is zero, you end up setting the $current_page to 1 - if ($current_page < 1) { $current_page = 1; } if ($current_page > $totalpages) { $current_page = $totalpages; } Should be - // limit the maximum first, then the minimum - if ($current_page > $totalpages) { $current_page = $totalpages; } if ($current_page < 1) { $current_page = 1; }
  8. The problem is probably in the code in the processQuery method.
  9. You code is apparently storing the key as the value, rather than the value as the value.
  10. Apparently the $player array doesn't contain the expected data. What does the following debugging code show and how is the data being put into the $players array? - echo "<pre>",print_r($player,true),"</pre>";
  11. Your code works for me, with some test data with ~50 rows. The only thing I noticed was a typo in the line of code I posted, which you would have also noticed if your error_reporting/display_errors settings were already set as suggested. While the error in the line of code I posted was not intentional, this points out why you need to have php's error_reporting and display_errors set as suggested to save you a huge amount of time when debugging. If you changed your master php.ini settings, you must stop and start your web server to get any changes made to take effect and you need to confirm using a phpinfo statement that the settings actually got changed in case the php.ini that php is using is not the one that you changed.
  12. Your code isn't setting the $pagenum variable from $_GET['pagenum'] $pagenum = isset($_GET['pagenum']) ? intval($_GET[$pagenum]) : 1; When developing and debugging php code, you need to have php's error_reporting set to E_ALL and display_errors set to ON to get php to help you by reporting and displaying all the errors it detects. You would have been getting an undefined error messages for $pagenum alerting you to the fact that it is not being set in your code.
  13. Because the upload is being handled by php on the server, you will be restricted by the size limits and file limit that are set on the server, no matter what you do on the client side. The swf/jquery based scripts upload one file per http request, so they are not bothered by the php max_file_uploads setting, but will still be stopped by the php upload_max_filesize/post_max_size settings. What exact problem are you trying to solve? Uploading a large number of files or uploading large files?
  14. ^^^ That sounds like hard-coding values/data rather than using variables/functions.... If you post an example showing what your code is doing and what exactly is different between these various 'calculators' (show two different ones), someone can suggest a general purpose method that does not involve the evil (the name it should have been given) statement.
  15. When developing and debugging php code, you need to have php's error_reporting set to E_ALL and display_errors set to ON so that php will report and display all the errors it detects. You also need to place echo statements in your code so that you can determine exactly what execution path your code is taking. Is your code even starting? Is the file being uploaded without any errors? Is your database code failing with an sql error of some kind?
  16. Here's a slight possibility for a php4 vs php5 explanation for this. IF (a big if) php4 produced an empty array when exploding an empty string, the for() loops would not run at all, whereas php5 definitely produces an array with one empty string element in it when exploding an empty or a non-existent string and the for() loops will run through one iteration.
  17. ^^^ That error is because the mysql_query() statement ISN'T executing the correct sql query statement. The sql statement is in $sql2, but the mysql_query() statement isn't using that particular variable.
  18. Here's a working example of the original posted code - <?php // some faked functions that modify the value for demo purposes function dowsncodes($var){return '[dc]'.$var;} function dosmilies($var){return '[ds]'.$var;} function parsemessage($var){return '[pm]'.$var;} function wraplines($var){return '[wl]'.$var;} class foo{ var $description = 'some thing'; // pretend the following properties, corresponding to the exploded settings strings in the following code, were dynamically created and assigned values, instead of being listed here var $cat1 = 'c1',$cat2 = 'c2',$cat3= 'c3'; var $smi1 = '(o',$smi2= '(;'; var $lbc1 = "a\nb",$lbc2 ="c\nd"; function bar(){ // fake a settings object that when referenced in the posted code, sets/references dynamically created properties $settings = (object)array('parsecodecategories'=>'cat1,cat2,cat3','smiliescategories'=>'smi1,smi2','linebreakcategories'=>'lbc1,lbc2','wordwrap'=>25); // an example of the $settings object that produces the OP's error //$settings = (object)array('parsecodecategories'=>'','smiliescategories'=>'smi1,smi2','linebreakcategories'=>'lbc1,lbc2','wordwrap'=>25); // original posted code $catloop = explode(',', $settings->parsecodecategories); for ($x=0; $x<sizeof($catloop); $x++) { $this->$catloop[$x] = dowsncodes($this->$catloop[$x]); } $catloop = explode(',', $settings->smiliescategories); for ($x=0; $x<sizeof($catloop); $x++) { $this->$catloop[$x] = dosmilies($this->$catloop[$x]); } $catloop = explode(',', $settings->linebreakcategories); for ($x=0; $x<sizeof($catloop); $x++) { $this->$catloop[$x] = str_replace("\n", "<br>", $this->$catloop[$x]); } $this->description = parsemessage($this->description); if ($settings->wordwrap > 0) $this->description = wraplines($this->description, $settings->wordwrap); } } $class = new foo; $class->bar(); echo "<pre>"; print_r($class); Output: foo Object ( [description] => [wl][pm]some thing [cat1] => [dc]c1 [cat2] => [dc]c2 [cat3] => [dc]c3 [smi1] => [ds](o [smi2] => [ds](; [lbc1] => a b [lbc2] => c d ) Output with the second example $settings object uncommented: Fatal error: Cannot access empty property in foobar.php on line 29 The indirect/variable/dynamic property syntax being used: $somevar = 'abc'; $this->$somevar (evaluates as $this->abc) was valid in php4 and is unlikely to be the cause of the problem the OP is having.
  19. Here's one way of doing this - 1) Write or find a calendar script that accepts the year and month number as input values for the calendar month to display. 2) Retrieve the events from your database table that match the year and month number you are trying to display. 3) Loop over the events you just retrieved from your database table and store them in an array of arrays, where the main array index is the YYYY-MM-DD date the event occurs on. The array under each date allows for multiple events on any particular day. 4) In your calendar script, when you are looping over the days in the month, form the YYYY-MM-DD value for the current day and use that to test if there are any events on that date in the array you made in step #3. If there are, loop over and output the events as links in the calendar. 5) Done.
  20. There's a problem with your $settings object. Either one of the $settings-> properties is empty or non-existent (null). The explode is producing an array with one empty string as an element and when you attempt to loop over this and dynamically create properties, you are getting that error. Does this have anything to do with php4 vs php5, I don't know. Php4 might have been treating this condition as a warning and continuing. It's more likely your settings don't exist and the code is not testing if the exploded string produced an array that contains settings to produce properties from. Short-answer: there's nothing technically wrong with the code and you should not be randomly trying different things in an attempt to get it to work. Find out why it is producing that error and fix the problem. Debug what is in the $settings object, using var_dump
  21. You have a mysql_close statement at line 72 in the code. Every mysql_ statement after that point will fail. Remove the mysql_close statement, it's not needed since the connection will be closed when the execution of the page ends.
  22. You must have missed this -
  23. You should be storing date or date/time values using mysql's native DATE or DATETIME data types, which have formats of YYYY-MM-DD or YYYY-MM-DD HH:MM:SS. You can add a DATE data type column to your table and populate it using one UPDATE query that uses the mysql STR_TO_DATE() function to read the existing column values and produce mysql DATETIME value. Since your existing values have the time, you would also need to use the mysql DATE() function to only get the date part. ref: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date
  24. The only thing javascript has the direct ability to do related to a web server is to make http requests to the web server. What exact problem are you trying to solve?
  25. This topic has been moved to Application Design. http://forums.phpfreaks.com/index.php?topic=361897.0
×
×
  • 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.