PHP - Having A Hell Of A Time With Arrays - Need Some Help Please.
Ok, I will explain first what I am trying to do, and show you how I am going about it, which isn't working
I have a table set up. It has missing ID numbers, such as, 1 2 3 6 7 8 11 12 ..etc. I am trying to pull a random ID number from all valid ID numbers. (Meaning, I don't want to get an ID of a record that is no longer there, so skip all the missing ID's) This is for a cron job to change which record is being shown each day, randomly. I figured, logically, the best way to do this would be to pull all the valid ID's into an array, and then use array_rand($id_array,1); to pull one random ID number out of the array. So, I tried using this code: Code: [Select] //Set variable as an array $id_array = array(); //Populate array with valid ID's $sql="SELECT ID FROM riddles"; $result=mysql_query($sql,$db) or die(mysql_error()); while($row = mysql_fetch_array($result,$db)) { $id_array[] = $row['ID']; }; print_r(array($id_array)); $new_rotd=(array_rand($id_array[0],1)); I am running into 2 problems with this code. First, when I print_r the array, I get the following: Quote Array ( => Array ( => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => [16] => [17] => [18] => [19] => [20] => [21] => [22] => [23] => ) ) The numbers are not correct. It is the correct number of total records, but it is not putting the correct ID number in there. 2) When I try and pull a random number out of the array, I get an error saying the First argument has to be an array. It IS an array?! I need to get this working, so any help would be much appreciated. To summarize I need to: Pull all valid ID #'s out of the table and put them in an array. Pull one random number out of that array and set it as variable: $new_rotd Similar TutorialsSo I wrote this code, what its supposed to do is draw an image on a grid space, based on its X,Y coordinates from a mySql database, compared to the player X,Y. Heres the code: Code: [Select] <table> <tr> <td> <?php //northwest echo "nw"; $x1 = $_SESSION[x] - 1; $y1 = $_SESSION[y] + 1; $hasobject1 = mysql_query("SELECT * FROM objects WHERE x='$x1' && y='$y1'"); while($row = mysql_fetch_array($hasobject1)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> <td><?php //north echo "n"; $x2 = $_SESSION[x]; $y2 = $_SESSION[y] + 1; $hasobject2 = mysql_query("SELECT * FROM objects WHERE x='$x2' && y='$y2'"); while($row = mysql_fetch_array($hasobject2)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> <td><?php //northeast echo "ne"; $x3 = $_SESSION[x] + 1; $y3 = $_SESSION[y] + 1; $hasobject3 = mysql_query("SELECT * FROM objects WHERE x='$x3' && y='$y3'"); while($row = mysql_fetch_array($hasobject3)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> </tr> <tr> <td><?php //wesr echo "w"; $x4 = $_SESSION[x] - 1; $y4 = $_SESSION[y]; $hasobject4 = mysql_query("SELECT * FROM objects WHERE x='$x4' && y='$y4'"); while($row = mysql_fetch_array($hasobject4)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> <td><?php echo "p"; //player echo "<IMG SRC='spaceship_wire5.jpg' WIDTH=64 HEIGHT=64>"; ?></td> <td><?php //east echo "e"; $x5 = $_SESSION[x] + 1; $y5 = $_SESSION[y]; $hasobject5 = mysql_query("SELECT * FROM objects WHERE x='$x5' && y='$y5'"); while($row = mysql_fetch_array($hasobject5)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> </tr> <tr> <td><?php //southwest echo "sw"; $x6 = $_SESSION[x] - 1; $y6 = $_SESSION[y] - 1; $hasobject6 = mysql_query("SELECT * FROM objects WHERE x='$x6' && y='$y6'"); while($row = mysql_fetch_array($hasobject6)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> <td><?php //south echo "s"; $x7 = $_SESSION[x]; $y7 = $_SESSION[y] - 1; $hasobject7 = mysql_query("SELECT * FROM objects WHERE x='$x7' && y='$y7'"); while($row = mysql_fetch_array($hasobject7)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> <td><?php //southeast echo "se"; $x8 = $_SESSION[x] + 1; $y8 = $_SESSION[y] - 1; $hasobject8 = mysql_query("SELECT * FROM objects WHERE x='$x8' && y='$y8'"); while($row = mysql_fetch_array($hasobject8)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> </tr> </table> Now what happens is it draws the image on a bunch of different spots. The object is at 0,0. It doesnt display the object if the object is out of range of the player, or the player is at 0,0. But if the player is near the object, it draws it on like half the grid spaces, and on some places everywhere but the players. Heres the page, login with test, password test. http://spacetimemmo.webuda.com/login.php Greetings to all! I am very new to this so I may not be on the right track. I am providing some code I have because I think this is the best way to explain what I am trying to do. I have a database and php pages that generate a pedigree when one selects any particular dog from the search page. If anyway has a tip on how to simplify this, I would sure appreciate it!! First, I request an array for the dog selected: Code: [Select] $sql = "SELECT RegName, SireID, DamID FROM pedigrees WHERE ID="; $thisDogQ = $sql . $values["ID"]; $thisDogR = db_query($thisDogQ,$conn); $thisDogRow_value = mysql_fetch_assoc($thisDogR); $thisDogRow_value = array ( 'RegName' => $thisDogRow_value['RegName'], 'SireID' => $thisDogRow_value['SireID'], 'DamID' => $thisDogRow_value['DamID']); </code> //Next I request the same information for his sire <code> if (is_numeric($thisDogRow_value['SireID'])) { $query_SireQ = $sql . $thisDogRow_value['SireID']; $SireR = mysql_query($query_SireQ, $conn) or die(mysql_error()); $SireRow_value = mysql_fetch_assoc ($SireR); $SireRow_value = array ( 'RegName' => $SireRow_value['RegName'], 'SireID' => $SireRow_value['SireID'], 'DamID' => $SireRow_value['DamID']); </code> //and then his dam <code> if (is_numeric($thisDogRow_value['DamID'])) { $query_DamQ = $sql . $thisDogRow_value['DamID']; $DamR = mysql_query($query_DamQ, $conn) or die(mysql_error()); $DamRow_value = mysql_fetch_assoc ($DamR); $DamRow_value = array ( 'RegName' => $DamRow_value['RegName'], 'SireID' => $DamRow_value['SireID'], 'DamID' => $DamRow_value['DamID']); </code> Now, here's the rub: Now I need the sire and the dam for those 2 [described above] so this time through, I will need the same information for FOUR dogs. The next time will be for EIGHT, then SIXTEEN - and so on until there are a total of 256 dogs. <code> //Get PatGrandSire 2 if (is_numeric($SireRow_value['SireID'])) { $PatGrandSireQ = $sql . $SireRow_value['SireID']; $PatGrandSireR = mysql_query ($PatGrandSireQ, $conn) or die(mysql_error()); $PatGrandSireRow_value = mysql_fetch_assoc ($PatGrandSireR); $PatGrandSireRow_value = array ( 'RegName' => $PatGrandSireRow_value['RegName'], 'SireID' => $PatGrandSireRow_value['SireID'], 'DamID' => $PatGrandSireRow_value['DamID']); //GetPatGrandDam 17 if (is_numeric($SireRow_value['DamID'])) { $PatGrandDamQ = $sql . $SireRow_value['DamID']; $PatGrandDamR = mysql_query ($PatGrandDamQ, $conn) or die(mysql_error()); $PatGrandDamRow_value = mysql_fetch_assoc ($PatGrandDamR); $PatGrandDamRow_value = array ( 'RegName' => $PatGrandDamRow_value['RegName'], 'SireID' => $PatGrandDamRow_value['SireID'], 'DamID' => $PatGrandDamRow_value['DamID']); //Get Pat1GGrandSire-3 if (is_numeric($PatGrandSireRow_value['SireID'])) { $Pat1GGrandSireQ = $sql . $PatGrandSireRow_value['SireID']; $Pat1GGrandSireR = mysql_query ($Pat1GGrandSireQ, $conn) or die(mysql_error()); $Pat1GGrandSireRow_value = mysql_fetch_assoc ($Pat1GGrandSireR); $Pat1GGrandSireRow_value = array ( 'RegName' => $Pat1GGrandSireRow_value['RegName'], 'SireID' => $Pat1GGrandSireRow_value['SireID'], 'DamID' => $Pat1GGrandSireRow_value['DamID']); if (is_numeric($PatGrandSireRow_value['DamID'])) { $Pat1GGrandDamQ = $sql . $PatGrandSireRow_value['DamID']; $Pat1GGrandDamR = mysql_query ($Pat1GGrandDamQ, $conn) or die(mysql_error()); $Pat1GGrandDamRow_value = mysql_fetch_assoc ($Pat1GGrandDamR); $Pat1GGrandDamRow_value = array ( 'RegName' => $Pat1GGrandDamRow_value['RegName'], 'SireID' => $Pat1GGrandDamRow_value['SireID'], 'DamID' => $Pat1GGrandDamRow_value['DamID'], 'Title' => $Pat1GGrandDamRow_value['Title'], 'Title2' => $Pat1GGrandDamRow_value['Title2'], 'Title3' => $Pat1GGrandDamRow_value['Title3'], 'Title4' =>$Pat1GGrandDamRow_value['Title4'], 'Title5' => $Pat1GGrandDamRow_value['Title5'], 'Title6' =>$Pat1GGrandDamRow_value['Title6'], 'Title7' => $Pat1GGrandDamRow_value['Title7'], 'Title8' =>$Pat1GGrandDamRow_value['Title8'], 'Title9' => $Pat1GGrandDamRow_value['Title9'], 'Addl_Titles' => $Pat1GGrandDamRow_value['Addl_Titles']); //Get Pat2GGrandSire-18 if (is_numeric($PatGrandDamRow_value['SireID'])) { $Pat2GGrandSireQ = $sql . $PatGrandDamRow_value['SireID']; $Pat2GGrandSireR = mysql_query ($Pat2GGrandSireQ, $conn) or die(mysql_error()); $Pat2GGrandSireRow_value = mysql_fetch_assoc ($Pat2GGrandSireR); $Pat2GGrandSireRow_value = array ( 'RegName' => $Pat2GGrandSireRow_value['RegName'], 'SireID' => $Pat2GGrandSireRow_value['SireID'], 'DamID' => $Pat2GGrandSireRow_value['DamID'], 'Title' => $Pat2GGrandSireRow_value['Title'], 'Title2' => $Pat2GGrandSireRow_value['Title2'], 'Title3' => $Pat2GGrandSireRow_value['Title3'], 'Title4' => $Pat2GGrandSireRow_value['Title4'], 'Title5' => $Pat2GGrandSireRow_value['Title5'], 'Title6' => $Pat2GGrandSireRow_value['Title6'], 'Title7' => $Pat2GGrandSireRow_value['Title7'], 'Title8' => $Pat2GGrandSireRow_value['Title8'], 'Title9' => $Pat2GGrandSireRow_value['Title9'], 'Addl_Titles' => $Pat2GGrandSireRow_value['Addl_Titles']); //Get Pat2GGrandDaminfo-25 if (is_numeric($PatGrandDamRow_value['DamID'])) { $Pat2GGrandDamQ = $sql . $PatGrandDamRow_value['DamID']; $Pat2GGrandDamR = mysql_query ($Pat2GGrandDamQ, $conn) or die(mysql_error()); $Pat2GGrandDamRow_value = mysql_fetch_assoc ($Pat2GGrandDamR); $Pat2GGrandDamRow_value = array ( 'RegName' => $Pat2GGrandDamRow_value['RegName'], 'SireID' => $Pat2GGrandDamRow_value['SireID'], 'DamID' => $Pat2GGrandDamRow_value['DamID']); Short version of my question is going to be "why are my session variables vanishing?" [ START not important Stuff ] My (simplified) site layout looks like login_page.php ->page1.php->page2.php login_page.php connects to mysql, to check login/pwd, and, if valid, sets the _SESSION id's/other credentials and then redirects to page1.php. page1.php has link to page2.php. Both page1 and page2 check against (require_once) an auth.php (authorization) and redirect to login_page.php if not logged in. The auth.php file has the structu session_start(); if(!isset($_SESSION['SESS_USER_ID'])|| other parameters){ //code } page2 has an AJAX load that pulls in a php file that includes various content (XML,text,.htm,etc.) That php file also requires auth.php All of these things work. [ END not important stuff ] [Start important part] Everything works. Session variables persist and are readable/accessible via all pages, as well as a Debug link (pop window that echos the $_SESSION vars.) UNLESSS the user is inactive for more than a minute or two; At which point the session variables vanish. Again, I can log in, Set the session variables, load multiple pages via AJAX (all of which are checked against the session variables...which means they have to exist) and generally everything works as expected. However, if I stop navigating/interacting with the site for more than a minute, or so, the session variables vanish (user id / other user credentials) and the I'm kicked back to the login the next time I click a link. There is nothing but the initial mysql login that writes to the session variables. No code, on any other page, does anything but read the session. My php ini file appears to have the correct location for my session.save_path. The garbage collection is the defualt 1440 and the cache_expire is also the default 180 I'm hosted with fatcow (starting to regret that) with Debian/Apache/php5 Oh and, this happens on every browser on Linux, Mac, and Windows. But it doesn't seem to occur if I run it locally from xampp/lampp. I'm at a total loss as to ideas for my next debugging step and any suggestions would be much appreciated. Hey guys havent coded in a while and im stumped. Ive checked google but to no avail lol i wanna include my config file and have an IF statement to run/include another file IE... <?php include("config/config.php"); If File(Not Exist); include("install/config.php"); ?> If someone can put me back on track it would be greatly epreciated <?php # Game Info # $game_link = "http://mob-dynamic-lb".rand(1,5).".mobsters0".rand(1,9).".com/mob/"; //$id2 = 548685167; # ID / Auth Key file info # $filename = "auth-keys111.txt"; $fp = file($filename); foreach($fp as $cwb){ list($id,$auth) = explode(" ",$cwb); $a = file_get_contents($game_link."attack?user_id=".$id."&target_id=548685167&punch_in_face=true&auth_key=".$auth); echo "WTF!"; //////////////////////////////////////////// //////////////////////////////////////////// $a = file_get_contents($game_link."attack?user_id=".$id."&target_id=548685167&punch_in_face=true&auth_key=".$auth); $b = file_get_contents($game_link."top_mob_gift?user_id=".$id."&target_id=".$id."&auth_key=".$auth); $c = file_get_contents($game_link."remove_top_mob?user_id=".$id."&target_id=548685167&auth_key=".$auth); echo "WTF?!";} ?> everything is correct for $game_link and all that.. but its not workin.. Any ideas? I have this thing that i am trying to make but i cant get it to work.. can anyone help? Code: [Select] function sql_read( $dbname,$dbusername,$dbpassword ) { $names = array(); $password = array(); $connect = @mysql_connect("mysql11.000webhost.com",$dbusername,$dbpassword) or die("Could Not Connect"); @mysql_select_db ($dbname) or die("Could not find DataBase"); $query = mysql_query("select * from users"); $numrows = mysql_num_rows($query); if ($numrows > 0){ while($row = mysql_fetch_assoc($query)){ $names[] = $row["uname"]; $password[] = $row["password"]; $id = $row["id"]; } $return = array($names,$password,$id); }else{ $return = array(); } return $return[]; } $names = array(); $names = sql_read("XXXXXX","XXXXXX","XXXXXXX")[0]; The error i get is Code: [Select] Parse error: syntax error, unexpected '[' in /home/a5480952/public_html/sql/index.php on line 28 Line 28 is "$names = sql_read("XXXXXX","XXXXXX","XXXXXXX")[0];" Please help... i REALLLLD need help with this.. ask questions if you want to know more about what i am trying to do... thanks! I'm having troubling with trying to create a function to spit out a single array with the following array. I can write it in a away that looks through the arrays manually. the results i am trying to generate is that each item in generated array. Array to convert array( "account" => array( "login", "register", "logout", "edit", ), "p" => array( "report", ), "array1.0" => array( "array2.0" => array( "array3.0", "array3.1 ), "array2.1", ), generating the array will look like this
Array ( [0] => account [1] => account/login [2] => account/register [3] => account/logout [4] => account/edit [5] => p [6] => p/report [7] => array1.0 [8] => array1.0/array2.0 [9] => array1.0/array2.0/array3.0 [10] => array1.0/array2.0/array3.1 [11] => array1.0/array2.1 ) The idea is that id generates a single array with combined labels and arrays inside, etc. I just can't figure out how to create a script that will create this array even If I add a new value or array.
PHP date and time function is not showing correct time on my local system I have the following php code date_default_timezone_set("Africa/Lagos"); $date = date('d-m-y h:i:s'); echo "Server Time ".$date ."<br>"; echo "The time is " . date("h:i:sa")."<br>"; $current_datetime = date("Y-m-d") . ' ' . date("H:i:s", STRTOTIME(date('h:i:sa'))); echo "Current time1: ".$current_datetime . "<br>";
Output
Server Time 21-05-21 09:55:39
Expected Output
Server Time 21-05-21 10:55:39
Any help would be appreciated. Edited May 21 by Ponel I have two arrays, both with the same key values. I'd like to combine them. So for instance... Code: [Select] <?php $array1['abcd'] = array( 'value1' => "blah", 'value2' => "blahblah"); $array1['efgh'] = array( 'value1' => "ha", 'value2' => "haha", 'valuex' => "xyz"); $array2['abcd'] = array('value3' => "three", 'value4' => "four"); $array2['efgh'] = array( 'value3' => "hohoho", 'value6' => "six6"); function combine_arrays($array1,$array2) { //*combining* return $single_array; } echo "<pre>"; print_r(combine_arrays($array1,$array2)); echo "</pre>"; /* would produce ['abcd'] = ( 'value1' => "blah", 'value2' => "blahblah", 'value3' => "three", 'value4' => "four" ) ['efgh'] = ( 'value1' => "ha", 'value2' => "haha", 'valuex' => "xyz", 'value3' => "hohoho", 'value6' => "six6" ) */ ?> What's the easiest way to do this? I am trying to simulate an ad expiration and carry out an action if the ad is expired. And I cannot get the if/else to work properly... I've tried many variations and I cannot see what I am doing wrong here. Any tips please 3 hours and counting of no solution! $ad_start = time()-14 . "<br />"; // 14 days from today in the past (negative) echo $ad_start; $current_time = time() . "<br />"; // current epoch time echo $current_time; $days_past = $ad_start - $current_time; // days past echo "<br />$days_past days have past since the ad started!<br />"; if($days_past <= 14) { echo "<br />Ad is less than 14 days. Not expired."; } else { echo "<br />Ad is over 14 days. Expired."; } Basically I have recently been playing around with parsing a csv file. What I am looking to do at this point is simply take the date/timestamp (part of the csv file), which is in the following format:DD/MM HH:MM:SS.100th/s For the sake of argument, lets say I have this in an array string called $csv[0] and the file has several lines that span the course of a couple hours. I wouldn't mind having to use explode() to breakup/remove the date or 100th/s IF that would make things a lot simpler. So where would I start in trying to achieve this?. The result I am looking for will simply return "X Seconds". Storing this in a string variable would be a bonus, as I plan to use this to divide a separate piece of information. Any examples or ideas would be great. Thank you. ps: Here is an example time from the csv file itself: Code: [Select] 11/19 22:23:18.143 I am having a problem with PHP displaying the correct date and time. It updates as it should, but is fast by 4min and is always displaying a date in 2004. I ran a basic php script to make sure the application im using itself is not wrong. go to lunenburgledger.com/time.php Anybody had any ideas on where to check? The system time on the Windows Server 2003 is correct. The only thing I can think of is that it was converted to a virtual machine on vmware esxi, but the system time stayed right. Any ideas? Thanks!
What are the differences and implications of UTC time and Zulu time? <?php function getArr(string $time):array { $dateTime = new \DateTime($time); return [ 'time'=>$time, 'timestamp'=> $dateTime->getTimestamp(), 'dateTime' => $dateTime ]; } $arr = getArr('2020-08-05'); $arr_z = getArr('2020-08-05T00:00:00Z'); print_r($arr); print_r($arr_z); echo('equal timestamps: '.($arr['timestamp'] === $arr['timestamp']?'true':'false'));
Array ( [time] => 2020-08-05 [timestamp] => 1596585600 [dateTime] => DateTime Object ( [date] => 2020-08-05 00:00:00.000000 [timezone_type] => 3 [timezone] => UTC ) ) Array ( [time] => 2020-08-05T00:00:00Z [timestamp] => 1596585600 [dateTime] => DateTime Object ( [date] => 2020-08-05 00:00:00.000000 [timezone_type] => 2 [timezone] => Z ) ) equal timestamps: true
PHP 5.2.6 We rent PHP server space on a server in California. Several of my pages generated by PHP show the current date and time, so when the page is printed, the user knows when the data was printed. Our users could be anywhere in the US, I am in Michigan. How do I convert the server time (PDT) into local time, regardless of where the user is? Thanks. This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=316461.0 Hello, I tried to implement some PHP code to enable a web page to show "Dinner" specials versus "Lunch" specials based on the time. The business is located in the Eastern Time Zone, so I only need to routine to work based on Eastern Time (New York). What I am noticing is that the server is processing the lines of code so fast that the command to establish the correct time for the remaining code is not always being acknowledged. This line of code appears to be processing too fast for the remaining lines of code: date_default_timezone_set ( "America/New_York" ); Is there some additional code I can put in place to make sure the correct time is always ascertained? I need the $hourmin variable to always return a combination of hour + minute based on 24-hour time and Eastern Time zone. My code is as follows: <?php $name8 = file_get_contents("test/special8name.txt"); date_default_timezone_set ( "America/New_York" ); $gethour = date("H"); $getminutes = $gettimedate["minutes"]; $gettimedate = date(); $hourmin = $gethour . $getminutes; $currentday = date("l", time()); $currentdate = date("M j, Y"); if ($hourmin < 1500 && $currentday <> "Saturday" && $currentday <> "Sunday") { echo "<span class=\"namesred\">$name8 </span>"; } else if ( $hourmin > 1500 && $hourmin < 2300 && $currentday <> "Saturday" && $currentday <> "Sunday") { echo "<span class=\"namesblue\">$name8 </span>"; } else if ( $currentday == "Saturday" or $currentday == "Sunday") { echo "<span class=\"namesblue\">$name8 </span>"; } ?> OK So I've got a datepicker that sends a date in d/m/y format. My DB stores the data in Unix Timestamp Which I can convert the date to with strtotime however this does the exact date & time. All I want is the actual day. I've spent hours trying to convert this with just the day with mixed results... Thanks. Let's say I am buying a share for $10. If I sell the share on the same day BEFORE 3:30PM, it will be sold for $10, but if I keep the share past 3:30PM, I want the code to automatically add $1 (Taxes and such) once in the the price of the share in database, after that no matter how many days pass by, the price will remain the same.
I've thought about CRON jobs, but I have no idea how to make/use them or set them up.
Any direction or help is appreciated.
I have this: $sql = mysqli_query($conn, "SELECT ip , page , CASE WHEN referrer = '' THEN 'N/A' ELSE referrer END as referrer , DATE_FORMAT(date, '%m/%d/%y') as date , TIME_FORMAT(time, '%T') as time FROM tblTraffic ORDER BY date DESC, time DESC"); most of my traffic report contains the correct times, my time, which is CST in the USA. but some records are off by a lot. Does the time() function capture the time of the actual location from which the visitor is coming from? if so, what could I do to return my timezone for any visitor? w3 schools and php.net don't mention this. Hi, The hosting provider for my domain confirm me that the server time is in EST (UTC-5). They also sent me a grab supporting that Code: [Select] server time is now: ---------------------- Sun Nov 7 02:20:01 EST 2010 ------------------- But when I use the following code, the output I get is has 1 hr difference (UTC-6) echo date("d M, Y h:i:s A",time()); Output==> 07 Nov, 2010 01:20:01 AM But it suppose to give the same time as the server, ryt? Can anybody please explain? Thanks, |