Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. Or you could just do this in your query (find if a value is in a list)- http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_find-in-set
  2. Perhaps if you describe exactly what you are trying to accomplish, someone can help? The query you posted to get help with and the image you posted don't suggest at all what you are trying to do, having something or nothing to do with matching dates in the data. Without a clearly defined statement of what you are trying to accomplish, it's difficult for you to accomplish anything and impossible for us to help.
  3. You would use OR in order to get both matching rows - WHERE date ='2011-07-14' OR date='2011-07-20' You want to match rows where date is '2011-07-14' or where date is '2011-07-20' You can also use IN() - WHERE date IN('2011-07-14','2011-07-20')
  4. What relationship exists between the rows in the two tables? You would generally join the two tables using that relationship, which would let you use SELECT COUNT1/COUNT2 as ratio and you would retrieve the ratio value along with all the other values when you iterate over the rows from the query.
  5. The second parameter of the date function is expected to be a Unix Timestamp. You can use the strtotime function to convert your $d['datetime'] value into a Unix Timestamp, or since you are apparently getting this value from a query statement, you can retrieve the value in the final format you want from your query using the mysql DATE_FORMAT function - http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format (doing this in a query is at least 8 times faster than using some slow parsed, tokenized, interpreted php code.)
  6. Here is what I would do. Your existing calendar logic already has the following code to determine and output class='today' or class='normal' - if($counter == $thisday){ echo "\t\t<td class='today'>$counter</td>\n"; // add class for today } else { echo "\t\t<td class='normal'>$counter</td>\n"; } Why not just modify that logic to do what you are trying to do. If you get your $eventarray data from the query and put it into the following format - $eventarray['2011-07-03'] = array(); // empty array used here assuming you will eventually put event information into the array() and use it in the calendar $eventarray['2011-07-04'] = array(); $eventarray['2011-07-05'] = array(); $eventarray['2011-07-06'] = array(); $eventarray['2011-07-15'] = array(); all you would need to do is change the if($counter == $thisday){ ... logic to the following - // make the yyyy-mm-dd date to match against the keys in the $eventarray $date = sprintf("%04d-%02d-%02d",$thisyear,$thismonth,$counter); if(isset($eventarray[$date])){ // there is an event(s) for today echo "\t\t<td class='date_has_event'>$counter</td>\n"; } else { // there is no event for today echo "\t\t<td class='normal'>$counter</td>\n"; }
  7. If the blog software is your own and you are willing to modify the php code or if you already have bbcode tags in use or your own tag/placeholder system in it, you would use the method that per1os posted. The %userip% is just some made up unique placeholder/tag that would be put into the text of a blog post at the point where you want to display the visitor's ip address. The str_replace() statement would be something that you add to your blog software at some point after you retrieve the content from the database and before you output the content of the blog post to the browser.
  8. I'm guessing you want a generic add on solution that doesn't require modifying your blog software? (the link you posted is for creating a web page that displays the visitor's ip address, not for a way of directly embedding the ability to display the visitor's ip address into a blog post.) To generically do this, you would either use an iframe or dynamically produce an image that displays the ip address. You would then insert either an <iframe src="URL"></iframe> tag or an <img src="URL" alt=""> tag into the blog post using bbcode tags, since most blog software would not permit direct insertion of html tags. For the iframe method, the URL would be to a .php script that does exactly what the link you posted is doing. For the image method, the URL would be to a .php script that dynamically produces and outputs an image using the GD image functions that writes the IP address onto the image.
  9. You are making this harder than it is. You would store the value that is in $_SERVER['REMOTE_ADDR'] with the saved blog post record in the database, say in a column named ip. To display the IP address when you display the blog post, you would use the following php code, assuming that $row is the associative array of data that was fetched from the database table - <?php echo 'Your IP is: ' . $row['ip']; ?>
  10. Do you want those to be defined constants or literal strings - define('EXTRACT_SYMBOL',1); // a constant or Strings - case 'EXTRACT_NUMBER': $cls->myFunction('Some string', 'EXTRACT_NUMBER');
  11. How did you obtain and install PHP? If you used the .msi installer package, you must use the Windows control panel add/remove menu to enable php language extensions. If you manually installed php from the .zip package, you need to make sure that the php.ini that you are changing is the one that php is using. The phpinfo() output Loaded Configuration File is the php.ini that php is using.
  12. The $securimage->check logic goes inside your form processing code.
  13. 'timestamp' is a string consisting of the letters t, i, m, e, s, t, a, m, and p. timestamp (with no quotes around it) is your column name.
  14. ^^^ You have commented out the exit; statement in the $securimage->check logic, so yes, the 'protected' code on the page will still be executed when the code does not match.
  15. Do you actually have an id with the value 2 in the table? Add echo statements (echo 'you are here' to your code so that you can tell if the block of code where the mysql_query() statement is at is actually being executed.
  16. You are using the uploaded file "name" in the imagecreatefrom... statement - $im = imagecreatefromjpeg($_FILES["image_id"]["name"][$j]); That's not where the image is at. You moved it to - "upload/gallery/" . $_FILES["image_id"]["name"][$j] and that is what you would need to put into the imagecreatefrom... statement.
  17. I'm not sure where you got that quote from in the documentation, but the only official information is - To determine if the row was not affected due to the data being the same or the WHERE clause being false, you would need to fist execute a SELECT query with the same WHERE clause. You would then know that the matching row exists and the update returned a zero for mysql_affected_rows() because the data being updated is the same as the old value.
  18. Have you done a 'view source' in your browser of the page?
  19. The php Warning: error you are getting (most likely) means that a query has failed due to an error (possibly a mysql connection problem, i.e. too many connections or connection has gone away...) and your code (most likely) has no error checking, error reporting/logging, and error recovery logic in it to get it to test for errors, report/log the errors that are occurring in the application, and take an appropriate action (don't execute follow-on code that is dependent on the previous step executing without errors.) You could also have an error in your logic that is causing the problem. However, without any error checking, error reporting/logging logic in your code to get your code to tell you what problems are occurring and where they are occurring at, the actual cause is just a guess. All applications should always test each mysql_connect, mysql_select_db, and mysql_query statement for errors and log the mysql_error information and in the case of a mysql_query, log the actual query statement. If you use trigger_error as part of the error reporting/logging logic, php can (assuming that you have error_reporting set to E_ALL, log_errors set to ON, and error_log is setup with a log file name to write to) write the information to a log file, which includes the file and line number (of the trigger_error statement) where the error is occurring at. Typical logic for a SELECT/SHOW query - $query = "SELECT * FROM your_table WHERE your_where_conditions..."; if(!$result = mysql_query($query)){ // query failed, handle the error here... $errors[] = "A fatal error occurred and this page is non-functional at this time!"; // setup a user error message trigger_error("Query failed: $query<br /> Due to: " . mysql_error()); // generate an application error message } else { // query worked, check if it matched any rows if(!mysql_num_rows($result)){ // no matching rows $main_content .= "There is no matching information...(for whatever the query was trying to do!)"; // use your own appropriate wording ... } else { // query matched at least one row, use the results from the query here... $row = mysql_fetch_assoc($result); // fetch one row or use a loop to iterate over all the rows // use the data that the query matched here... } } // code having nothing to do with the success or failure of the above query goes here... If you set the error_reporting/log_errors/error_log settings as indicated, the trigger_error statement will log the $query and the mysql_error that is occurring. If you set display_errors to ON, you will get more immediate feedback because the information will also be output to the browser.
  20. It would probably help if you showed your mysql query and php code that is retrieving the data and how the data is associated to the correct level (your $ndot1, $ndot2,... values.)
  21. You would extract the portion of your stored dates that you want to match (there are a bunch of mysql date/time functions to do this) and compare them either with specific numbers (2011 for this year or 7 for this month) or you can dynamically extract the current year and/or current month - SELECT * FROM counter WHERE YEAR(your_date_time_column) = 2010; -- match all the rows from last year SELECT * FROM counter WHERE YEAR(your_date_time_column) = YEAR(CURDATE()); -- match all the rows from the current year SELECT * FROM counter WHERE MONTH(your_date_time_column) = 6; -- match all the rows from the month of June (all years) SELECT * FROM counter WHERE MONTH(your_date_time_column) = MONTH(CURDATE()); -- match all the rows from the current month (all years) SELECT * FROM counter WHERE EXTRACT(YEAR_MONTH, your_date_time_column) = EXTRACT(YEAR_MONTH, CURDATE()); -- match all the rows from the current year and current month SELECT * FROM counter WHERE EXTRACT(YEAR_MONTH, your_date_time_column) = 201012; -- match all the rows from 2010 December (month 12) You can also use a BETWEEN min AND max comparisons to match dates over any range of dates you want (multi years, multi months...)
  22. Your code is not setting the $name, $subject, $msg, and $headers variables, so of course it will be a little difficult for the email to get sent.
  23. Because your setcookie statement has single-quotes around user - "te['user']", the array key is literally - " 'user' " You would need to use echo $_COOKIE['te']["'user'"]; or simply remove the single-quotes so that your setcookie is - "te[user]"
  24. Because you are using a heredoc string to make your form, everything you put between the starting and ending <<<_HTML_ tags is part of that string. Don't use the dot . concatenation operator (the dots and any extra quotes become part of the string.) Just put php variables directly inside a heredoc string without any concatenation.
  25. Here's the first statement written out with all the qualifications and conditions, since it was apparently misunderstood - because each folder (except the disk root) has a . and .. entry, you will get a TRUE from the is_dir() (for the . and .. entry, what this sentence is referring to), no matter where your script is executed at.
×
×
  • 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.