Jump to content

justarandomguy

New Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by justarandomguy

  1. Here i am again with another (probably) silly question. I have a table and want to have 2 timestamps in it, one for 'created' and the other for 'updated'. I haven't been able to make those two fields work the way i want which is well.. created set when the entry is done and updated when it is updated (duh!). Before moving on i'd like to say that I'm a total n00b at this, the little i know is because google is good at answering questions The fields are: name: updated (this actually works fine, saves the time the record is created (and hence, updated) type: timestamp Default: current_timestamp Attributes: on update Current_timestamp name: created type: timestamp default: as defined: 0000-00-00 00:00:00 (not sure why really, it just made it that way) the queries i have tried: INSERT INTO tbl_process (updated, created, stuff, morestuff, etcetc) VALUES (DEFAULT, DEFAULT, '$stuff', '$morestuff', '$etcetc') INSERT INTO tbl_process (stuff, morestuff, etcetc) VALUES ('$stuff', '$morestuff', '$etcetc') In both cases 'created' just saved '0000-00-00 00:00:00'. 'updated' did save the time correctly. I tried reading the documentation but could make any sense of it: http://dev.mysql.com/doc/refman/5.0/en/timestamp.html I know that I'm probably doing all wrong but if you could find the time to help i'll appreciate it very much Thank you!
  2. Hello again; I'm trying to build a little php site and some with mysql, when a record is saved on the DB i want a column with the timestamp. I've been doing a bit of reading and *i think* the database part is done but i cant figure how the insert should be done. The column on mysql is: Type: timestamp Default: current_timestamp Attributes: on update current_timestamp The structure on the table is: id, timestamp, column1, column2. I thought that since it is 'on update current_timestamp' it would fill itself properly, but when i do my insert: $query = "INSERT INTO tbl_process VALUES ('','','$value1','$value2')"; mysql_query($query) or die ("Error in query: $query " . mysql_error()); The only saved value is "0000-00-00 00:00:00" so obviusly i'm missing something... for extra points: the 'id' value is autoincrement so on the insert i just leave the value empty with ''. Is that the "correct" way of filling that field or is there a "best practice" for that? Thanks everyone
  3. so... kenrbnsn I tried using the little part that you added at the beginning of your reply, i didn't have that and i guess its a good idea: $client = (isset($_GET['client'])?$_GET['client']:'NoClient'; but im getting: Parse error: syntax error, unexpected ';' in C:\wamp\www\data.php on line 10 if i remove the ; of course i get another error. I feel kind of ashamed of myself for asking but i dont really know how is that working so i cant fix it myself... do you know whats missing? Thanks again
  4. Gotcha Mahngiel Ill remember that tip Thanks!
  5. holy.... that was fast! Thank you very much, it is working now! I didnt know i could use ' instead of " on the html part, i dont have to \" or concatenate with . now. Again, thanks a lot!
  6. Hello; I'm new to php and to programming in general, but i want to do a little app to help a process on my work, you know, just being pro-active (hoping it doesnt come and byte me in the a** in the future, you know.. "you did it now our life depend on it and you fix it right now!!). So.. I have this really simple piece of code, but its not working and i cant figure out why. I'm trying to use echo to print a couple of link but when i put in the second line everything messes up. the code is: (note the "test lines" i just added them to try to understand what is doing) <?php $client = $_GET['client']; echo "Client " . $client . "<br />"; echo "test line 1"; echo "<a href=\"link1.php?client=".$client.">Link 1</a><br>"; echo "test line 2"; echo "test line 3"; echo "<a href=\"link2.php?client=".$client.">Link 2</a><br>"; ?> When i open the page on firefox i get: === Client myclient test line 1Link 2 === Where the link (underlined) text is "Link 2" but the it points to something totally different (a mix of the rest of the code). If I remove the second link, like here: <?php $client = $_GET['client']; echo "Client " . $client . "<br />"; echo "test line 1"; echo "<a href=\"link1.php?client=".$client.">Link 1</a><br>"; echo "test line 2"; echo "test line 3"; ?> I get what i'd expect: === Client myclient test line 1Link 1 test line 2test line 3 === Im totally lost, im not sure if its a browser issue, a server issue or just the code My setup: WAMP 2.1 (Apache) I'm opening the "site" with Firefox 3.6.15 and IE6, both show the same result Windows XP (dont know if it matters) The file is saved as php tried changing "echo" with "print", same result Umm.. thats it... Please let me know if you need any more info Thanks everyone edit: typo on subject edit: yet another typo
×
×
  • 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.