Page 1 of 1
database querying question
Posted: Tue Jul 29, 2003 8:41 pm
by m3rajk
ok. i'm about to implement a dabase and enter the next stage of testing a site i'm making.
i have aquestion before i do ... when i connect to the mysql database, if the user can only use one databse, do i need to select a db orr is it automatically selected???
thanx in advance
Posted: Tue Jul 29, 2003 9:28 pm
by jmarcv
try it <grin>
Posted: Tue Jul 29, 2003 10:12 pm
by fractalvibes
Yes, you do:
$conn = mysql_connect("localhost","userid","pass") or die ("Cannot Connect to Database!");
$db = mysql_select_db("MyDB", $conn) or die ("Cannot Connect to Database");
Otherwise the DBMS will not know!
Phil J.
Posted: Tue Jul 29, 2003 10:22 pm
by jmarcv
Some times computers are not logical....
Posted: Tue Jul 29, 2003 11:32 pm
by m3rajk
thanx fractal. i figured as much but wasn't sure.here's a followup, for one of the dbs i wanna enter the current date in datetimeformat when an entry is made, would that work right if i passed it NOW() as the value?
Posted: Wed Jul 30, 2003 4:33 am
by twigletmac
m3rajk wrote:for one of the dbs i wanna enter the current date in datetimeformat when an entry is made, would that work right if i passed it NOW() as the value?
Have you tried it?
Mac
Posted: Wed Jul 30, 2003 10:37 am
by m3rajk
not yet, every time i think i'm ready to make the database one of the ones i;m working with decides there needs to be a new feild, so i then give them another day to figureout if we've missed something...result: i'm preparing the php for the db, but am holding off on making the db since some tables (specifically the main one) keeps getting modified
Posted: Wed Jul 30, 2003 10:56 am
by jmarcv
> i wanna enter the current date in datetimeformat when an entry is made, would that work right if i passed it NOW() as the value?
Thats one way. The other is to make your field a timestamp and it will automatically do that. A note, though, timestamp auto-updates EVERY time you edit the record, (I use it for last-updated type fields)
So if you want the date the record was entered, perhaps try setting the default in the field definition as NOW(). I am FAIRLY certain you can use a function as a default value and eliminate the need to bother with it in your code.
Been lazy, always will be lazy.
Posted: Wed Jul 30, 2003 3:08 pm
by m3rajk
this is for comments. they wont be updateable. but that's good to know because i plan to make a forums later from scratch to accompany the profiles i'm making.
backstory: i keep gettng told i don't have the db/php experience needed to get jobs, a friend wants her own rateme site and is great with graphics. we're teaming up. we're deciding layout and functionality together, but she she doesn't even knwo html i'm doing ALL the coding and leaving ALL the graphics to her. so it'll show off db/php abilities. we're adding some features not on other rateme sites so that we can have a hook of being more than a simple rateme site...
Posted: Wed Jul 30, 2003 5:46 pm
by jmarcv
>backstory: i keep gettng told i don't have the db/php experience needed to get jobs
Whatever. I got my experience from jobs. I got them. I compensated for my lack of knowledge, and now I have the experience. Don't let peoples opinions dissuade you. They are probably just trying to limit the competition anyway.
Posted: Wed Jul 30, 2003 6:13 pm
by m3rajk
no. that's what i'm hearing from employers when they tell me that i didn't get the job i applied for advertised as entry level (the fact i got the same responses when looking for internships all four years of college are what lead to my signature)
Posted: Wed Jul 30, 2003 7:52 pm
by m3mn0n
down with corporations!