PHP - Datetime Field Problem
I am trying to import into a csv file and filter the results to a particular user and only results based on the time the data was uploaded within one hour. In other words anything not uploaded within the last hour of the start_time will not appear in the csv file. Everything works fine except for the time part. I get no results at all with the 'and unix_timestamp........ For all I know possibly I am way off with my effort. The field name is start_time. Here is code below. Appreciate any help.
<code> header('Content-type: application/csv'); </code> Similar TutorialsHello, I am trying create a news article, but I have few category in it. Can you help me to create an "add article form" which has dropdown list of category that I can choose, so when I select "Announcement" it will save the data on my mysql database under announcement table. sample html form below. <form id="form1" name="form1" method="post" action=""> <label> Category : <select name="category" id="category"> <option>--- choose category ---</option> <option>News</option> <option>Announcement</option> <option>Sports</option> </select> </label> <br /> Date: <br /> Title: <label> <input type="text" name="title" id="title" /> </label> <br /> Body: <label> <textarea name="body" id="body" cols="45" rows="5"></textarea> </label> <br /> <label> <input type="submit" name="Submit" id="Submit" value="Submit" /> </label> <br /> <br /> </form> Can you tell me how to create the php code which support the above html. Also, I would like to have a date and time on my article, but I want it automatically get the time and date from the computer of the client, so the user will not put it manually. can you point me to the correct code? Thanks and hope you can help me! Hi, basically i am parsing some rtf/word files and generating excel csv's for upload into mysql database....my issue is in one of the fields i want to store the value in the mysql datetime / date format but excel keeps reformating it. Any help on how to overcome this will be highly appreciated. Dear all, how can I convert a string "yyyy-mm-dd hh:mm" into a really datetime value with php? thanks! Hi: I'm going crazy trying to do the following: I'm making a job registration process where the user registers on one php page to the website, must acknowlege and email receipt using an activate php page, then is directed to upload their C.V. (resume) based on the email address they enter in the active page output. I then run an upload page to store the resume in teh MySQL db based on the users email address in the same record. If I isolate the process of the user registering to the db, it works perfectly. If I isolate the file upload process into the db, it works perfect. I simply cannot upload teh file to the existing record based on teh email form field matching the user_email field in the db. With the processes together, teh user is activated, but teh file is not uploaded. Maybe I've simply been at this too long today, but am compeled to get through it by end day. If anyone can help sugest a better way or help me fix this, I will soo greatly appreciate it. My code is as follows for the 2 pages. ---------activate.php------- <?php session_start(); include ('reg_dbc.php'); if (!isset($_GET['usr']) && !isset($_GET['code']) ) { $msg = "ERROR: The code does not match.."; exit(); } $rsCode = mysql_query("SELECT activation_code from subscribers where user_email='$_GET[usr]'") or die(mysql_error()); list($acode) = mysql_fetch_array($rsCode); if ($_GET['code'] == $acode) { mysql_query("update subscribers set user_activated=1 where user_email='$_GET[usr]'") or die(mysql_error()); echo "<h3><center>Thank You! This is step 2 of 3. </h3>Your email is confirmed. Please upload your C.V. now to complete step 3.</center>"; } else { echo "ERROR: Incorrect activation code... not valid"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Job application activation</title> </head> <body> <center> <br/><br/><br/> <p align="center"> <form name="form1" method="post" action="upload.php" style="padding:5px;"> <p>Re-enter you Email : <input name="email" type="text" id="email"/></p></form> <form enctype="multipart/form-data" action="upload.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="4000000"> Upload your C.V.: <input name="userfile" type="file" id="userfile"> <input name="upload" type="submit" id="upload" value="Upload your C.V."/></form> </p> </center> </body> </html> --------upload.php---------- <?php session_start(); if (!isset($_GET['usr']) && !isset($_GET['code']) ) { $msg = "ERROR: The code does not match.."; exit(); } if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $email = $_POST['email']['user_email']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } include 'reg_dbc.php'; $query = "UPDATE subscribers WHERE $email = user_email (name, size, type, content ) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$content')"; mysql_query($query) or die('Error, query failed'); mysql_close($dbname); } ?> <center> <br/> <br/> <br/> <br/> Thank you for uploading your <?php echo "$fileName"; ?> file, completing your registration, and providing us your C.V. for this position. <br/> <br/> <br/> We will contact you if your canditature qualifies. </center> I have such a little code. If I echo $order_date, I receive normal date in YYYY-MM-DD format. But when I use $order_date in mysql query it is not showing me anything. I do not receive any error or warning also. Please help me. $query = "SELECT Product,Amount FROM orders WHERE Date='$order_date'"; $result = mysql_query($query) or die(mysql_error()); while($products_list = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $products_list["Product"] . "</td>"; echo "<td>" . $products_list["Amount"] . "</td>"; echo "</tr>"; } This code gives me 1969-12-31 18:33:30 Code: [Select] <?=date('d M Y', $val['Created']);?> and this one gives me 2010-11-04 03:52:54 WHICH IS THE RIGHT ONE - BUT i need to format as above. Code: [Select] <?=$val['Created']?> this happens on the same line of code. What is wrong? Hello All, I have the following code: Code: [Select] echo "<table width='615px' cellpadding='3' cellspacing='4' align='center'>"; echo "<tr>"; echo "<td align='left' width='150px'>"; echo substr($row['date'],0,11); echo "</td>"; echo "<td align='left' width='465px'>"; echo $row["food"] ; echo "</td>"; echo "</tr>"; echo "</table>"; And this outputs: Apr 4 2011 Chicken Ceasar Salad, Garlic Toast, Cloddhoppers, Applesauce, & Milk (etc.) How can I add "Mon" in front of "Apr 4 2011"? thanks! I'm using mcrypt to encrypt a field and decrypt it. That works OK. But when I insert the encrypted field into a mySQL table, select it, decrypt it and try to display it, I get garbage. What am I missing? Thanks for any suggestions. Here's the code: echo "The encrypt and decrypt example...<br/>"; // Designate string to be encrypted $string = "Ed O'Reilly"; // Encryption/decryption key $key = "arG4thaker2"; // Encryption Algorithm $cipher_alg = MCRYPT_RIJNDAEL_128; // Create the initialization vector for added security. $iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher_alg, MCRYPT_MODE_ECB), MCRYPT_RAND); // Output original string print "Original string: $string <p>"; // Encrypt $string $encrypted_string = mcrypt_encrypt($cipher_alg, $key, $string, MCRYPT_MODE_CBC, $iv); // Convert to hexadecimal and output to browser print "The encrypted string: ".bin2hex($encrypted_string)."<p>"; $decrypted_string = mcrypt_decrypt($cipher_alg, $key, $encrypted_string, MCRYPT_MODE_CBC, $iv); print "The decrypted string: ".rtrim($decrypted_string).""; echo "<br/>testing db storing & retrieval for the encryption/decryption...<br/>"; # make connection (Game server connections are variable and are done later when needed) if (!$cxnAdmin = mysqli_connect($hostAdmin, $userAdmin, $passwordAdmin, $dbnameAdmin)) { die("Could not connect to MySQL server Admin (".mysqli_connect_error().")"); } $sql="INSERT INTO testdb.nametable ( name, ) VALUES ( '$encrypted_string', 'test@test.com' ) ; "; $result = mysqli_query($cxnAdmin,$sql); if($result == false) { echo "<h4>Error on nametable Insert: ".mysqli_error($cxnAdmin)."</h4>"; } $sql="SELECT name FROM testdb.nametable WHERE email='test@test.com'"; if (!$result = mysqli_query($cxnAdmin,$sql)) { echo "<h4>Error on nametable Select: ".mysqli_error($cxnAdmin)."</h4>"; } $row = mysqli_fetch_assoc($result); extract($row); // Convert to hexadecimal and output to browser print "The encrypted string from db: ".bin2hex($name)."<p>"; $decrypted_name = mcrypt_decrypt($cipher_alg, $key, $name, MCRYPT_MODE_CBC, $iv); print "The decrypted string from db: ".rtrim($decrypted_name).""; and here's the output: The encrypt and decrypt example... Original string: Ed O'Reilly The encrypted string: 01bc70f5dc5a7ca204cb45bd2eeb0214 The decrypted string:Ed O'Reilly testing db storing & retrieval for the encryption/decryption... The encrypted string from db: 5938f7fc81961d2efc6db64607baf465 The decrypted string from db: <garbage characters I can't display here> Hi Everyone, Please have a look at this, and tell me if its right? I am generating a sitemap for my website dynamically. The date I am providing: 2012-02-24 11:56:09 and this is the output I am getting: 2012-02-24T11:56:09Z now I am not sure of the Z at the end of the returned value. I think I am looking for something similar to this: 2012-03-12T12:00:02+02:00 not to sure what I am doing wrong and where it gets the timezone from, I am guessing from the php config file. any help would be much appreciated. thanks My code: Code: [Select] <lastmod><?php echo $time->toAtom($post['Post']['modified']); ?></lastmod> Hi, I'm a newbie here, and with PHP, and need some help with the datetime display. I am wanting to utilize old Naval comms DTG (datetimegroup) format which is DDHHMM 3-digit Month 2-digit year. The DDHHMM = Day (01 - 31) HH (hour 01 - 24) MM (minute 00 - 59) What I need to do is to add the letter Z (meaning GMT, ZULU) like thus DDHHMMZ FEB 11 How can I go about inserting that Z into this? Tks in advance for any assist Basically I am using DATETIME to store the time in which a row was input. Format - 2010-11-13 21:31:53 How would I get the current time of page load and compare it to the database row "2010-11-13 21:31:53" then output the difference. Example $sqlresult = 2010-11-13 21:31:53; $currentTime = (GET CURRENT DATE+TIME = (2010-11-13 21:31:55) ); Output - This was posted 2 minute's ago. Thank you in advance. Any help would be greatly appreciated. I'm given something like this: Sun Nov 06 2011 09:30:00 GMT-0500 (EST) And i'm trying to turn that into 2011-11-06 09:30:00 I started by using explode and trying to loop through the day and month to figure it out, but that seems inefficient and overly complicated. Am i missing something? Thanks Hello!! i want to save datetimes into a mysql database. Their format is dd-mm-yy hh:mm. I think mysql format for datetime is yy-mm-dd hh:mm..How can i convert them?? Hey, does anybody know a good function, where I can have the trendy "time ago" functionality?
A good tutorial would be cool, too.
I would be using the datetime function off MySQL.
Code: [Select] OFXAdapter: Failed to parse request: Unable to parse an atomic field "OFXRequest.OFXRequest.SignOnMsgsRqUn.SignOnMsgsRqV1.SonRq.DtClient": field value "20101005091544.000[-4:EDT]" is not a valid (YYYYMMDDHHMMSS.XXX[gmt offset:tz name]) date. I am trying to put together some PHP code to use the OFX standard to communicate with my bank in order to download my recent transactions. The standard details that in the sign-on request, the date and time must be included in the format listed above. As you can see, I have the value in the exact same format as specified. So my question is this: is there something about GMT offset or TZ names that I am missing here? Hi FYI I'm a n00b in this particular forum & php n00b really but I'm having a problem & cant find a solution anywhere! I need to be able to send an email from a form. Within the form is a dropdown field for different regions. When a region is selected it sets the email address for that region into an input/text field. I need to pickup that value and send the email to that address but not sure how. Have been told to use echo$email & that perhaps my variable is empty but I haven't got a clue where to put it or what that means. Help please?! my code: include ('maketable.php'); include ('mailbot.php'); include ('auditFile.php'); $office = $_REQUEST["office"]; $callername = $_REQUEST["callername"]; $callerphone = $_REQUEST["callerphone"]; $callaction = $_REQUEST["callaction"]; $callerInfo = "Callers Name=".$callername; $commentInfo = "Callers Phone No=".$callerphone; $callDetail = "Action Taken=".$callaction; $title = "DOC Call Results"; $stylesheet = "stylesheet.css"; $logo = "tcclogo.jpg"; $display = makeHeader($title,$stylesheet,$logo); $display .= makeTable("Caller Details",$callerInfo,1); $display .= makeTable("",$commentInfo,1); $display .= makeTable("",$callDetail,1); $display .= '</body></html>'; $info = $callerInfo."; ".$commentInfo."; ".$callDetail; auditFile($title, $info); echo $email; mailbot($title,$display,"email","info@tcc.co.nz","ThankYou.html"); i have a with my script I made a basic messaging service for my website. I have a form with a textarea as an input variable. It inserts the textarea value to a database using a php script upon form submission. The SQL field is set as longtext so the user can insert a large text string. There's a few things i need to do to perfect it. I need to make it so the user can only insert text characters, so not to allow script manipulation; and I need to figure out why it's deleting my intro message when changing the `read` field from `unread` to `read`. The `messages` SQL table is separated into 6 fields: to, from, message, read, subject, and number. when the user reads a message, i have a php script that reads as follows: <?php include("include/session.php"); function curPageName() { return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1); } $pagename = curPageName(); $replaced2 = eregi_replace("message", "", $pagename); $number = eregi_replace(".php", "", $replaced2); mysql_select_db("******_starcraft") or die(mysql_error()) ; $query = " SELECT * FROM `messages` WHERE number='$number' "; $result = mysql_query($query); $info = mysql_fetch_array ( $result ); $to = $info['to']; $from = $info['from']; $subject = $info['subject']; $message = $info['message']; $read = $info['read']; mysql_query("DELETE FROM `messages` WHERE `number`='$number'") ; mysql_query("INSERT INTO `messages` VALUES ('$to', '$from', '$message', 'read', '$subject', '$number')") ; ?> Now, after trouble shooting, i found that the problem is occuring when it tries to insert the $message string into the third field of the `messages` table. I find this strange because when you send the message to this user using the "compose message" script, the input variable is inserted into the database table without a stitch. Is there something i'm missing? i feel like it's on the tip of my tounge... thanks in advance, -dan
Hi guys, <form id='contact-form".$KitchConfigID."' name='contact-form".$KitchConfigID."' action='_pages/_kitchenconfig/adm_saveKitchConfig.php?Nav=".$NavHash."&kcid=".$KitchConfigID."' method='POST'> <div class='row'> <div class='col-sm-12'> <div class='md-form mb-0 form-sm'> <input value='".$KitchConfig."' type='text' id='configname".$KitchConfigID."' name='configname".$KitchConfigID ."' class='form-control'> <label for='configname".$KitchConfigID ."' class=''>Config Name:</label> </div> </div> </div> <div class='row'> <div class='col-sm-12'> <div class='md-form mb-0 form-sm'> <select id='designer_".$KitchConfigID."' name='designer_".$KitchConfigID."' class='mdb-select md-form' searchable='Search here..' onchange='changeInput(this.value, ".$SelField.");'>"); $designersql = "SELECT * FROM `tbl_contacts` ORDER BY `FirstName`"; $resultdesigner = $conn->query($designersql); if ($resultdesigner->num_rows > 0) { $resultdesigner->MoveFirst; echo("<option value='designer_".$KitchConfigID."'></option>"); while($rowdesigner = $resultdesigner->fetch_assoc()) { $DesignerName = $rowdesigner["FirstName"]." ".$rowdesigner["LastName"]; $DesignerID = $rowdesigner["ContactID"]; if($rowdesigner["ContactID"]==$rowkitch["Designer"]){ echo("<option value='".$DesignerID."' selected='selected'>".$DesignerName."</option>"); } else { echo("<option value='".$DesignerID."'>".$DesignerName."</option>"); } } } echo("</select> <input type='text' name='".$SelField."' value='' /> <label for='designer_".$KitchConfigID."' class=''>Designer:</label> </div> </div> </div> <div class='md-form mb-0 float-right'> <button type='submit' class='btn btn-outline-danger waves-effect btn-sm float-right'>Save <i class='fas fa-magic ml-1'></i></button> </div>
$upd_KitchConfigID = $_GET["kcid"]; if(isset($_POST["configname$upd_KitchConfigID"])) { $upd_KitchConfig = $_POST["configname$upd_KitchConfigID"]; } else { $upd_KitchConfig = 'NotSet'; $ErrMsg = $ErrMsg . 'No KitchConfig, '; } if(isset($_POST["designer$upd_KitchConfigID"])) { $upd_KitchConfigDesigner = $_POST["designer_$upd_KitchConfigID"]; } else { $upd_KitchConfigDesigner = 1; $ErrMsg = $ErrMsg . 'No Designer, '; } echo("designer_$upd_KitchConfigID: ".$_POST["designer_$upd_KitchConfigID"]."<br><br>");
This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=351353.0 hey guys, i have my code set up to run substrings through a db to check for matches...even when there is a match it wont insert correctly Code: [Select] $result = mysql_query("select * from friends where userid=$userid"); while($row = mysql_fetch_assoc($result)) { $first_name = $row['first_name']; $last_name = $row['last_name']; $strpos_1 = strpos($friend_1, ' '); $substr_1 = substr($friend_1, 0, $strpos_1); $substr_2 = substr($friend_1, $strpos_1); if($substr_1 == $first_name && $substr_2 == $last_name) { $sql = "insert into fav_friends values('', '$userid', '$friend_1', '$friend_2', '$friend_3', '$friend_4', '$friend_5', '$friend_6')"; $query = mysql_query($sql); } } and i don't receive any errors, any thoughts? |