PHP - Xampp Timezone Error
I have a Xampp Timezone Error
Error Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for '-5.0/no DST' instead in C:\Users\cory j\Desktop\xampp\htdocs\NoXIp\Toplist\inc\vote.php on line 56 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' NOW())' at line 1 Line 56 $diffrence = time() - strtotime($getDate['lastVoteDate']); The Date Function in Php.ini [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = "America/New_York" date.timezone = "America/New_York" ; http://php.net/date.default-latitude ;date.default_latitude = 31.7667 ; http://php.net/date.default-longitude ;date.default_longitude = 35.2333 ; http://php.net/date.sunrise-zenith ;date.sunrise_zenith = 90.583333 ; http://php.net/date.sunset-zenith ;date.sunset_zenith = 90.583333 Similar TutorialsHi folks, I am a complete n00b at php and mysql. I am teaching myself from books and the WWW, but alas I am stuck... the error I get is: Parse error: syntax error, unexpected T_STRING in X:\xampp\htdocs\search.php on line 7 here is the code: <?php mysql_connect ("localhost", "user", "password") or die (mysql_error()); mysql_select_db ("it_homehelp_test") or die (mysql_error()); $term = $_POST['term']; $sql = $mysql_query(select * from it_homehelp_test where ClientName1 like '%term%'); <<<------this is line 7 while ($row = mysql_fetch_array($sql)){ echo 'Client Name:' .$row['ClientName1']; echo 'Address:' .$row['Address1']; echo 'Phone:' .$row['Tel1']; } ?> Any help you can offer would be great. I can also post the ".html" file that creates the search bar if it is needed. Thanks
Hi im coding a php form using a tutorial im completely new at php need help what am i doing wrong Parse error: syntax error, unexpected T_IF in C:\xampp\htdocs\admin\updates_details.php on line 278 while ($data = mysqli_fetch_array($r, MYSQLI_ASSOC)) { echo '<table width="100%" border="1" cellpadding="5" cellspacing="5"> <tr> <td width="11%"><strong>Download</strong></td> <td width="34%"><strong>Update By: ' . $data['update_by'] . '</strong></td> <td width="48%"><strong>Date Created:</strong> ' . $data['dr'] . '</td> <td width="7%"><a href="delete.php?item=update&id=' . $data['update_id'] . '"><img src="../images/delete-icon.png" width="24" height="24" alt="delete" /></a></td> </tr> <tr> <td colspan="4">File: ' . if($data['file'] == 'Yes'){ $data['file']; } . 'Click Here to Download</td> </tr> <tr> <td colspan="4"><p>' . $data['update_msg'] . '</p></td> </tr> </table>'; } // End of WHILE loop. <?php class Post{ private $user_obj; private $con; public function __construct($con, $user){ $this->con = $con; $this->user_obj = new User($con,$user); } public function submitPost($body,$user_to){ $body = strip_tags($body);////Removing HTML TAGS $body = mysqli_real_escape_string($this->con,$body); $check_empty = preg_replace('/\s+/', '', $body);//delte all spaces if($check_empty != ""){ //Current Date and time $date_added = date("Y-m-d H:i:s"); //get username $added_by = $this->user_obj->getUsername(); //if user have not a profile send to the none if($user_to == $added_by){ $user_to = "none"; } ////insert query $query = mysqli_query($this->con,"INSERT INTO posts VALUES('','$body','$added_by','$user_to','$date_added','no','no','0')"); $retured_id = mysqli_insert_id($this->con); //insert notification //Update post count for user $num_post = $this->user_obj->getNumPosts(); $num_post++; $update_query = mysqli_query($this->con,"UPDATE users SET num_post = '$num_post' WHERE username = '$added_by'" ); } public function loadPostsFriends(){ $str = ""; //string to return $data = mysqli_query($this->con,"SELECT * FROM posts where deleted = 'no' ORDER by id DESC"); while($row = mysqli_fetch_array($data)) { $id = $row['id']; $body = $row['body']; $added_by = $row['added_by']; $date_time = $row['date_added']; /// Creating user post on other user profile if($row['user_to'] == "none"){ user_to = ""; else { $user_to_obj = new User($con,$row['user_to']); $user_to_name = $user_to_obj->getFirstandLastname(); $user_to = "to <a href='" . $row['user_to'] . "'>" .$user_to_name . "</a>"; } // check if user account was closed $added_by_obj = new User($this->con,$added_by); if($added_by_obj ->isClosed()){ continue; } $user_details_query = mysqli_query($this->con,"SELECT first_name,last_name,profile_pic FROM users where username = '$added_by'"); $user_row = mysqli_fetch_array($user_details_query); $first_name = $user_row['first_name']; $last_name = $user_row['last_name']; $profile_pic= $user_row['profile_pic']; ///time stamp $date_time_now = date("Y-m-d H:i:s"); $start_date = new Date_Time($date_time);////Time_of_post $end_date = new Date_Time($date_time_now);///Current_time $intervel = $start_date->diff($end_date); if($intervel->y >< 1 ){ if($intervel ==1 ) $time_message = $intervel->y . " year ago";/// 1 Year Ago else $time_message = $intervel->y . " years ago"; //1+ year ago } else if($intervel-> m >= 1 ){ if($intervel->d == 0){ $days = " ago"; } else if($intervel->d == 1){ $days = $intervel->d."day ago"; } else { $days = $intervel->d."day ago"; } if($intervel->m == 1){ $time_message = $intervel->m." month".$days; } else $time_message = $intervel->m." months".$days; } } else if($intervel->d >= 1){ if($intervel->d == 1){ $days = "Yesterday"; } else { $days = $intervel->d."days ago"; } } else if($intervel->h >= 1){ if($intervel->h == 1){ $time_message = $intervel->h." hour ago"; } else { $time_message = $intervel->h." hours ago"; } } else if($intervel->i >= 1){ if($intervel->i == 1){ $time_message = $intervel->i." minute ago"; } else { $time_message = $intervel->i." minutes ago"; } } else{ if($intervel->s < 30){ $time_message = "Just Now"; } else { $time_message = $intervel->s." seconds ago"; } } $str .= "<div class='status_post'> <div calss='post_profile_pic'> <img src='$profile_pic' width='50'> </div> <div calss='posted_by' style='color#ACACAC;'> <a href = '$added_by'> $first_name $last_name </a> $user_to ; ; $time_message </div> <div id = 'post_body'$body<br></div> </div> " } echo $str; } } ?> When i run this code this show me the error Parse error: syntax error, unexpected 'public' (T_PUBLIC) in C:\xampp\htdocs\social\Classes\Post.php on line 39 the line 39 is public function loadPostsFriends() I check the code again and again but i cant find the error please help in this error Ok well i have a virtual world, my friendcoded the emulator. In PHP but he's on holiday for 2 weeks. I keep getting Quote PHP Warning: PHP Startup: It is not safe to rely on the system's timezone setti ngs. You are *required* to use the date.timezone setting or the date_default_tim ezone_set() function. In case you used any of those methods and you are still ge tting this warning, you most likely misspelled the timezone identifier. We selec ted 'Europe/London' for '0.0/no DST' instead in Unknown on line 0 PHP Warning: eval(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone _set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ' Europe/London' for '0.0/no DST' instead in C:\inetpub\wwwroot\main\server\chapat iz.php(2) : eval()'d code on line 4 But there are only 4 lines in chapatiz.php and it has nothing to do with it i think Quote <?php eval(file_get_contents('serv_original.ini')); ?> Here's chapatiz.php (Its attached since its big) Quote //config $socketurl = "munizonline.co.uk; $httpurl = "munizonine.co.uk; $rootPath = "c:/inetpub/wwwroot/"; // SQL SETTINGS $host = 'localhost'; $user = 'root'; $dbname = 'chapatiz'; $password = '---'; $sqli = new mysqli("p:". $host, $user, $password, $dbname); // create a persistant sql connexion (keepAlive) $banned_ips = array(); ///// ADD BAN BY IP FROM HTACCESS $filename = $rootPath.".htaccess"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); $contents = utf8_decode($contents); $ex = explode("\n", $contents); $exf = array(); foreach ($ex AS $k => $str) { if(preg_match('`deny from (.*?) \#`', $str, $sortie)) { $return = $sortie[1]; array_push($exf, $return); } } foreach ($exf AS $k => $str) { array_push($banned_ips, $str); } // LOG ALL ACTIONS function dolog($text) { $myFile = "c:/inetpub/wwwroot/main/log/chat.txt"; $fh = fopen($myFile, 'a'); fwrite($fh, $text. "\n"); fclose($fh); } function serve($r) { return file_get_contents('C:/inetpub/wwwroot/main/server/serve/'. $r. '.php'); } function getitems($name) { return file_get_contents('http://munizonline.co.uk/main/items.php?u='. $name); } function haveitem($name, $item) { $c = file_get_contents('http://munizonline.co.uk/main/items.php?u='. $name); $pattern = '/"'. $item .'"/'; $pattern2 = '/"0'. $item .'"/'; if ((preg_match($pattern, $c)) OR (preg_match($pattern2, $c))) { return true; } else { return false; } } function dotag($tag) { $tag = explode('##', $tag); $tags = array(); foreach ($tag AS $k => $v) { list($name, $value) = explode('=', $v); $tags[$name] = $value; } return $tags; } function updatetag($tags, $tochange, $value) { $tags[$tochange] = $value; $new = "##"; foreach ($tags AS $k => $v) { $new .= $k. "=". $v. '##'; } return $new; } ini_set('display_errors', '1'); error_reporting(0); $quete8 = $sqli->query('UPDATE phpbb_users SET online = 0'); function cmd() { return false; } $modee = false; session_start(); $_SESSION['start'] = "yess"; $mainsock = socket_create(AF_INET, SOCK_STREAM, 0); //modifiez la prochaine ligne si besoin $pport = rand(81, 8000); while (!socket_bind($mainsock, $socketurl, $pport)) { $pport = rand(81, 8000); echo "\n port modified to ". $pport. "\n"; } $myFile = $rootPath."main/server/socket.php"; $fh = fopen($myFile, 'w+') or die("can't open file"); fwrite($fh, $socketurl. ":". $pport); fclose($fh); socket_set_nonblock($mainsock); socket_listen($mainsock); $clients=Array(); $compteur=0; $write = NULL; $except = NULL; $lol = NULL; $race = "0"; $flag = "0"; date_default_timezone_set('Europe/London'); $ok_marry = "0"; $ok_pv = "0"; function random($car) { $string = ""; return $string; } function random3($car3) { $string3 = ""; return $string3; } function random2($car2) { $string2 = ""; return $string2; } function random1($car1) { $string1 = ""; return $string1; } echo("Waiting for players!\n"); $file = file_get_contents($rootPath.'main/server/server_while.php'); $lasteval = time(); while(true){ if ($lasteval <= strtotime('-1 minute')) { if (file_exists($rootPath."main/server/server_while.php")) { $file = file_get_contents($rootPath.'main/server/server_while.php'); } $lasteval = time(); echo "\neval again\n\n"; } eval($file); } I have no clue whats wrong it use to work. Hi,
Please help to resolve this script.
Default time zone is not working properly it shows time only in AM (PM is not working) and in the INDIAN time 7:00pm to 7:00am table never fetch any content.
<div class="cart"> <table width="100%" height="100%" cellspacing="0" cellpadding="10"> <tbody> <tr style="margin: 5px; padding-bottom: 5px; background-color:#ececec; line-height:30px"> <td style="width: 10%;"> <span> Sr. No. </span> </td> <td style="width: 15%;"> <span> Order Id </span> </td> <td style="width: 35%;"> <span> Order Date / Time </span> </td> <td style="width: 10%;"> <span> Amount </span> </td> <td style="width: 35%;"> <span> Coupon Name </span> </td> <td style="width: 10%;"> <span> Action </span> </td> </tr> <tr> <td colspan="5" height="10"></td> </tr> <?php date_default_timezone_set("Asia/Dili"); $session_user_id = $_SESSION['userId']; $ordercount=1; $current_date = date('Y-m-d'); $order_id = $_SESSION['new_order_id']; $query = "select * from cs_order where order_id = '$order_id'"; if(!($result = mysql_query($query))) { echo $query.mysql_error(); exit; } $order_items = mysql_fetch_array($result); $order_transaction_id = $order_items['order_transaction_id']; $order_transaction_date = $order_items['order_transaction_date']; $order_currency_id = explode(", ", $order_items['order_currency_id']); $order_amount = $order_items['order_amount']; $order_coupon_id = explode(", ", $order_items['order_coupon_id']); $new_order_currency_id = $order_currency_id[0]; if(strtotime(date('Y-m-d', strtotime($order_transaction_date)))==strtotime($current_date)) { ?> <tr> <td style="width: 10%;"> <span> <?=$ordercount; ?> </span> </td> <td style="width: 10%;"> <span> <?=$order_transaction_id; ?> </span> </td> <td style="width: 25%;"> <span> <?=date('d M Y / h:i a', strtotime($order_transaction_date)); ?> </span> </td> <td style="width: 10%;"> <span> <?=$new_order_currency_id; ?> <?=$order_amount; ?> </span> </td> <td style="width: 25%;"> <span> <?php $user_id = $_SESSION['userId']; $current_date = date('Y-m-d'); $order_id = $_SESSION['new_order_id']; $query = "select * from cs_order as ord left join cs_countries as country on ord.order_country = country.country_id left join cs_states as state on ord.order_state = state. state_id left join cs_cities as city on ord.order_city = city. city_id where ord.order_id = '$order_id' and ord.order_user_id = '$user_id' and ord.order_transaction_date like '$current_date %:%:%'"; if(!($result = mysql_query($query))) { echo $query.mysql_error(); exit; } $total_invoice_amount = 0; while($invoice = mysql_fetch_assoc($result)) { $invoice_record[] = $invoice; } ?> <?php echo $invoice_record[0]['order_coupon_name']; ?> </span> </td> <td style="width: 15%;" align="center"> <span> <form action="" method="post" name="formGetcode"> <?php foreach($order_coupon_id as $coup_id) { $checkout_couponid = $coup_id['order_coupon_id']; $checkoutquery = "select * from cs_coupons as coup left join cs_company as comp on coup.coupons_store = comp.retailer_id where coup.coupons_id = '$checkout_couponid'"; if(!($checkoutresult = mysql_query($checkoutquery))) { echo $checkoutquery.mysql_error(); exit; } $coupon = mysql_fetch_array($checkoutresult); $checkout_couponurl = $coupon['coupons_website']; $coup_type = $coupon['coupons_type']; ?> <?php if($coup_type=='R') { ?> <button class="submit button" type="button" onclick="getCodePopup(<?=$checkout_couponid; ?>, '<?=$checkout_couponurl; ?>');" style="font-size:11px;width:86px;">Get Code</button> <?php } else { ?> <button class="submit button" type="button" onclick="getPrintPopup(<?=$checkout_couponid; ?>);" style="font-size:11px;width:86px;">Print Coupon</button> <?php } } ?> </form> </span> </td> </tr> <?php $ordercount++; } ?> <tr> <td colspan="5" height="20"></td> </tr> </tbody> </table> </div> </div><!--cart container close here--> And <script type="text/javascript"> function getCodePopup(str1, str2) { var cid = str1; var curl = str2; window.open('getcouponcode.php?id=' +cid, 'open_window', ' width=540, height=480, left=0, top=0'); window.open(curl,'_blank'); } function getPrintPopup(str1) { var cid = str1; window.open('printCoupon.php?id=' +cid, 'open_window1', ' width=640, height=320, left=0, top=0'); } </script>Pop Up code not fetching Coupon ID after number 9. Please help me to solve this. Thanks. Paresh Edited by mac_gyver, 13 June 2014 - 03:09 AM. code tags please Hey, practicing my PHP for the first time, starting with a simple upload script with Xampp. Script: Code: [Select] $target = '/Uploads'; $uploadedfile = $target . basename($_FILES['file']['name']); if(move_uploaded_file($_FILES['file']['tmp_name'], $target)){ echo "The file ". basename($_FILES['file']['name'])." has been uploaded."; } else { echo 'Failed'; } error_reporting(E_ALL); It echos out a successful, but the file is nowhere? Uploads is inside htdocs. Checked my php.ini file: file_uploads = On upload_tmp_dir = "C:\xampp\tmp" upload_max_filesize = 128M Just wondering if there are any permission i may have missed? I am working from my home computer using windows 8.1. I downloaded Xampp, installed notepad++ and created a simple echo statement using PHP. I then placed the statment into the htdocs file. Then I went to my browser and entered the path as localhost:81/invoice.php (I used 81 because 80 is used for another application). I also changed all of the locations where it defaulted to 80 (using the find function, so I know I covered them all). I still recieved this message below. I know they are seeing each other for two reasons.. 1. I get another error message when I make up a fake file path in localhost folder. 2. The error is a 404. Also, I can see Xampp dashboard at localhost:81/xampp. I am stumped. Could it be my security settings or the fact that I am on a home server? Also, could it be problem with having mysql and microsoft sql server 2008 R2 on the same machine? Any help would be awesome. Also, yes my Xampp is started up (Apache and Mysql). Thanks.
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404 localhost Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3 Edited by Butterbean, 18 December 2014 - 11:16 PM. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=312186.0 Hi Guys.
Doing an assignment for uni, and stuck on an error. Ill attach some files to show the problem and any help very much appreciated.
Error and the screen it comes on
Code
<?php $select = mysqli_query($con, "SELECT * FROM categories");
while ($row = mysqli_fetch_assoc($select)) { }
function dispsubcategories($parent_id) {
}
function getnumtopics($cat_id, $subcat_id) {
and the structure of the database
Edited March 28, 2020 by Ben555 I am in need of a script that can detect a visitors timezone with out using geoip and with out the user providing the information. Any help on this or references would be greatly appreciated. Quote Strict Standards: DateTime::__construct() [datetime.--construct]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Chicago' for 'CDT/-5.0/DST' instead in /home/elliottw/public_html/login/inc/conn.inc.php on line 45 And the code I am using is: $timezone = new DateTimeZone("Europe/London"); $date = new DateTime(); $date->setTimezone($timezone); $dateTime = $date->format('H:i:s d/m/Y'); $sqlDateTime = $date->format('Y-m-d H:i:s'); I've come to the end of my tether. I can't see anything wrong with this, searched Google and I'm starting to go crazy (partly due to the Caffeine and staring at code for 4 hours). Any help would be greatly appreciated! Cheers. hey im writing a page that does the timezones for 5:00 around the world and i found this template the only thing is it didnt include the timezone.php file the js is loading this new Ajax('timezone.php?tz='+String(timezone),{onComplete:tzCLB, method: 'get'}).request(); what it does is retrieves a list of countries from that file i think. How and what would i need to do to make a timezone.php that would get the countries. Thanks I just upgraded from 5.2.x to 5.3.3 this morning, and am now confronted with the "infamous" Code: [Select] It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for '-5.0/no DST' instead in C:\Inetpub\wwwroot\ATSTest\sys\class\class.calendar.inc.php on line 98 Previously I just let php pull the system time to keep everything accurate with DST. Now that I'm having to use the date.timezone setting in php.ini, how can I tell it to factor in DST, or do I now have to manually perform a calculation in my methods/functions to check and adjust? Or does it automagically recognize the DST by setting it to Code: [Select] date.timezone = America/New_York (yeah, right...what are the odds of *that*? instead of js alert displaying the timezone offset, i would like the content of get_time_zone_offset() to be used as a php variable.
<script type="text/javascript"> function get_time_zone_offset( ) { var current_date = new Date(); return -current_date.getTimezoneOffset() / 60; } alert("The local time zone is: GMT " + get_time_zone_offset()); </script> How would I change the current timezone used within a php script? The method I usually use, date_default_timezone_set() is undefined on my webhost, so I am trying to find another way. Hi, I am trying to get the date and time that a particular table was last updated, which the code below does, but it doesn't seem to be putting it in the correct timezone, it is 5 hours behind, anyone know why this is? or how i can fix it? Thanks Code: [Select] <?php date_default_timezone_set('Europe/London'); $query = "SELECT UPDATE_TIME FROM information_schema.tables WHERE TABLE_SCHEMA = 'tffdb' AND TABLE_NAME = 'test_team_points'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_assoc($result); echo $row['UPDATE_TIME']; ?> Developing apps is great until I have to start dealing with blasted timezones. For some reason this aspect of it always does my head in. At the moment I'm storing all dates in the DB as GMT with the format Y-m-d H:i:s. I figure it's good to be consistent and store dates in GMT then convert to the users desired timezone. So I allow users to choose there timezone, based off the defined PHP timezones that can be used with the DateTimeZone class. My problem, however, arises with the whole syncing of times. Let's say I post something right now. The date gets stored in in the database as: 2012-04-14 02:35:49 Now I'm in GMT +10 (possibly the greatest of timezones ), so I've set my timezone in my settings as Australia/Melbourne and when displaying date/times locally I do something like this: Code: [Select] public static function local($user, $date, $format = 'F j, Y, h:ia') { $date = new DateTime($date); return $date->setTimezone(new DateTimeZone($user->timezone))->format($format); } So running the stored date above through my method gives me a date like this: April 14, 2012, 12:35pm Awesome. My question is: I noticed that on say, Twitter, when you change your timezone your tweet dates don't change. They remain as the date/time of my actual timezone, regardless of what I set it too. With my implementation however, if I change my timezone to GMT +12 (Fiji) my post is now posted at: April 14, 2012, 02:35pm So is what I'm doing right? My head has about had it. Thanks. I have an idea, which I'm trying to realise, im using the time() function to store the timestamp within my db...and within the db I have a timezone column (which contains the timezone selected by that user). So I'd like to display $row['timestamp'] (the stored timestamp generated by time()) to the specified timezone, how would that work? <?php //$timestamp = timestamp generated by the time() function //$timezone = the timezone to convert $timestamp too function convert_time($timestamp, $timezone) { //$new_timestamp = do something to adapt $timestamp to $timezone //return the formatted/readable date... return date('D M Y H:i', $new_timestamp); } ?> |