PHP - Oop Datetime Extension Easy Question
So I am extending the DateTime class and would like to completely disable the modify() function that is built in so i have this:
Code: [Select] <?php class NewDateTime extends DateTime { public function modify() { throw new Exception('modify() has been disabled.'); } } thats not the entire class description, just the pertinent part of course now any time I create a new object from NewDateTime I get this message at the top of the screen: Quote Strict Standards: Declaration of NewDateTime::modify() should be compatible with that of DateTime::modify() in C:\xampp\htdocs\.....my file path here.....\NewDateTime.php on line 62 what gives? how do I get rid of this and still disable modify()? I'm betting its a setting that i have wonky but I am really rusty in php so dont know where to look in php.ini Similar TutorialsDear all, how can I convert a string "yyyy-mm-dd hh:mm" into a really datetime value with php? thanks! Right now I'm working on a simple register form and I have included the theme. I set up a div and positioned the div below the register form to output any error in red text. If I were to use code like this if(empty($_POST['username']) || empty($_POST['password']) || empty($_POST['email']) || empty($_POST['Veremail'])){ $required_info = "All three fields are required to continue!"; } It will not work, because I don't have a die(); or end(); function, so it will display: " All three fields are required to continue! and You have been successfully registered! " BUT IT'S IN THE CORRECT PLACE UNDER THE FORM WHERE I PLACED THE DIV. So I made this change if(empty($_POST['username']) || empty($_POST['password']) || empty($_POST['email']) || empty($_POST['Veremail'])){ $required_info = die("All three fields are required to continue!"); } and it worked fine, but now, the words are not positioned under the form, but at the bottom of the page, I'm wondering how I would end that script, but align the text so it displays underneath the form, and not at the bottom of the page? If you don't understand ask me please. I want to know can we do text formatting to a result coming from echo if so then kindly guide how? I need make error lower then 3 and higher then 15 how should i add higher then 15? Code: [Select] if (strlen($searchTerms) < 3) { $error[] = "Add more then 3 symbols and less then 15!"; }else { $searchTermDB = mysql_real_escape_string($searchTerms); // prevent sql injection. } While going through an instructional book, I ran across some code that I didn't immediately understand. I've stripped it down to the relevant bits: function example($object_a, $object_b) { $compare = $object_a->id == $object_b->id; return another_function('argument 1') && $compare || another_function('argument 2'); } My first confusion was this line: $compare = $object_a->id == $object_b->id; Does this set $compare to TRUE if the ids match and FALSE if they do not? And the second confusion: return another_function('argument 1') && $compare || another_function('argument 2'); What is returned if the ids match? What is returned if they are different? When I try testing this out on my machine, it returns both functions whether or not the ids match, but I know that's not what's supposed to happen. Can anyone break this down for me? Thanks. Hey people! I've been setting a coding script for experience and this is my situation: To buy a virtual flower, one needs to have 50 virtual coins. So I first extract the number of coins the person has from the DB. If the user doesn't have the sufficient number of coins, the BUY button will not be available and vice versa. When the BUY button is clicked, I update the database, adding the flower to the user's inventory and subtracting 50 from the total number of coins the user has. This I do in that page itself using if(isset($_POST['submit'])) Now, I need to know how I could check whether the user has at least 50 coins even if the button is available. I hope that you could understand this. I want to do it for validation purposes. Its to prevent the user spending the coins he has in another browser window and then returning to the visible button to click it. I hope that I make sense. Thanks in advance! Regards, Thauwa hello. i want to know what is *$ or +$ because i see it in many contact forms. also, what is the difference between these: /^[A-Z]+[a-z]*$/ /^[A-Z]+[a-z]+$/ /^[A-Z]+[a-z]$/ /^[A-Z]+[a-z]/ also, which is the shortest and efficient method of checking somebodys name to be exactly "Name Surname" - "Green Trancer" ? in my form, i use var filter = /^[A-Z]+[a-z]*$/; var filter2 = /^[A-Z]+[a-z]+\s+[A-Z]+[a-z]+$/; and then i check the name to be like filter or filter2. how can i check that between the words to be exactly one space character ? thank you very much. Hello Everybody
I usually work with C#, but I'm doing a website right now and have a question:
I want a picture in my header and when I change the window size the image may not move.
My code so far:
#a1 { position: relative; top:-175px; left:0px; width:50px; height:50px; background-image:url(http://domain.png); background-repeat:no-repeat;} </style>Hope someone can answer this question easy I'm trying to search the 'ad' column where 'ad' = 1 or 3 I'm having problems doing this. Here is what I currently have, but it is not bringing back 'ad' where ='1' (for obvious reasons) Quote $query = "SELECT * FROM users WHERE ad='3' AND state='$state1'"; Here is what I thought would work, but it displays every listing in my database when I do it this way. Quote $query = "SELECT * FROM users WHERE ad='3' OR ad='1' AND state='$state1'"; Thank you in advance for your answers, google is not being so kind to me right now. Wow, am I glad I found this forum! I spent the past few hours trying to modify a PHP/mySQL script in order to test it. What this script does is basically look up a mySQL database (based on ip2nation) to find out what country and currency the IP address belongs to. This is the code sample: Code: [Select] $sql = 'SELECT c.country, c.curr_code FROM ip2nationcountries c, ip2nation i WHERE i.ip < INET_ATON("24.24.24.24") AND c.code = i.country ORDER BY i.ip DESC LIMIT 0,1'; $countryName = $db->get_sql_row($sql); I tested the code in PHPmyAdmin and it returns 2 rows: country ------- curr_code (row names) United States ------- USD (actual values) So basically 2 variables, United States and USD. Now comes the problem, in order to test the script for several countries, I need to be able to "override" the result in the PHP script I tried to do that by commenting out the part that returns the result from the mySQL query and modifying it with the following style, but I think I'm doing something wrong: Code: [Select] ### $countryName = $db->get_sql_row($sql); ### $countryName = "United States USD"; Is there any way that I can temporarily override the result returned by mySQL and "fake it" so to say? I understand the mySQL query returns 2 rows, so how would I go about overriding 2 rows? I hope this makes sense ...you're all my last hope. How can I use an include file that has a list of links in any directory at my website without breaking those links? You can see it in action here... The links in this directory work... https://www.billelgin.com/primary-directory/ The links in this directory (being created from the same include file) do not work... https://www.billelgin.com/primary-directory/subsection-one/ Obviously the problem is the include file is being called from different directories, so it's breaking the relative path links in the include file, but what can I do to fix it? You can download the example directory structure here... https://www.billelgin.com/EXAMPLE.zip I am very new to php and am trying to create a simple application that uploads a PDF file to a database. I have one field for the Volume Number and on file field for the PDF to be uploaded. My issue is i can't get the PDF to upload or insert the name of the pdf (eg volume1.pdf) into the data base. I would also like to point out that I know i have a low post count, but i only seek help when i truly need it and have exhausted all other resources... Here is what i have, please go easy on me this is my first round at php: Code: [Select] <?php if(isset($_POST['submit'])){ $vol_num = $_POST['vol_num']; $pdf = $_FILES['pdf']['name']; $path = '../pdf/'.$_FILES['pdf']['name']; move_uploaded_file($_FILES["pdf"]["tmp_name"], $path); mysql_query("INSERT INTO volumes set vol_num='$vol_num', vol_link='$pdf'") or die (mysql_error()); echo "<script>location.href='add_volume.php'</script>"; } ?> what am i doing wrong here? Thanks in advance Alright, so I just started picking up PHP again and I have a pretty simple question. I have a html form that takes a string then writes it on another page. My problem is when I use quotations I'll get slashes in them on the page it writes the string on. Is there a way to clean that stuff up? 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! 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> 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.
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?? 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 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. |