lil question
Moderator: General Moderators
lil question
ok my teacher at school today told to do someting with creating table insert information select, update and delite. i got the first part done.. i have just got stuck at the insert part.
my teacher gave me a link to a website about to make it. i understand what it says i just have no idea how to actualy make it myself with the table i made.
http://www.php-mysql-tutorial.com/mysql-insert-php.php
this is how they tell me to do it just for some reason i can't figure out how to change that into the table i use :S
i don't know if it is needed but i'll but it here anyway
the names of the thingys i used in the table are:
Project_id
Project_description
Start_date
End_date
Last_modification_date
my teacher gave me a link to a website about to make it. i understand what it says i just have no idea how to actualy make it myself with the table i made.
http://www.php-mysql-tutorial.com/mysql-insert-php.php
this is how they tell me to do it just for some reason i can't figure out how to change that into the table i use :S
i don't know if it is needed but i'll but it here anyway
the names of the thingys i used in the table are:
Project_id
Project_description
Start_date
End_date
Last_modification_date
Re: lil question
Code: Select all
<?php
// include 'library/config.php';
// include 'library/opendb.php';
// mysql_select_db($mysql);
$query = "INSERT INTO user (host, user, password, select_priv, insert_priv, update_ priv) VALUES ('localhost', 'phpcake', PASSWORD('mypass'), 'Y', 'Y', 'Y')";
mysql_query($query) or die('Error, insert query failed');
// $query = "FLUSH PRIVILEGES";
// mysql_query($query) or die('Error, insert query failed');
// include 'library/closedb.php';
?>Line 6 is the query - the thing you want to change.
The basic syntax for an INSERT query is
Code: Select all
INSERT INTO table (field1, field2, field3, ...) VALUES (value1, value2, value3, ...)Re: lil question
i knew that but i don't know how to use the table i made wel had to make and fill it in there.
like with the begin date end date etc. and then make it a form of it.
like with the begin date end date etc. and then make it a form of it.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: lil question
What do you mean by "I don't know how to use the table"?
Re: lil question
it just confuses me all trying to fill it in can't seem to do it the right way and make it working.
this is what i have till now but i got stuck there
i have the includes also because i did it step by step so i use difrent files to connect to the db etc.
Code: Select all
<?php
include 'config.php';
include 'opendb.php';
mysql_select_db($dbname);
$query = "INSERT INTO user (Project_name, Project_description, Start_date, End_date, Last Modification date, update_ priv) VALUES ('projectname', 'the discription',yyyy-mm-dd', 'yyyy-mm-dd', now())";
mysql_query($query) or die('Error, insert query failed');
$query = "FLUSH PRIVILEGES";
mysql_query($query) or die('Error, insert query failed');
?>
i have the includes also because i did it step by step so i use difrent files to connect to the db etc.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: lil question
You're missing ' from your start date in values() and the field counts don't match. update_ priv no value in values().
Also, MySQL will not like 'YYYY-m-d' if your field's datatype is date (which it should be).
Also, MySQL will not like 'YYYY-m-d' if your field's datatype is date (which it should be).
Re: lil question
Code: Select all
<?php
include 'config.php';
include 'opendb.php';
mysql_select_db($dbname);
$query = "INSERT INTO user (Project_name, Project_description, Start_date, End_date, Last Modification date, update_ priv) VALUES ('projectname', 'the discription',date(), date(), now())";
mysql_query($query) or die('Error, insert query failed');
$query = "FLUSH PRIVILEGES";
mysql_query($query) or die('Error, insert query failed');
?>
Re: lil question
Is your table named `user` ? Your teacher told you to program a site using SQL but didnt teach you concepts of tables and fields and how they go into queries? 
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: lil question
You also have blank spaces in your table's field names: "Last Modification date" use underscores "Last_Modification_date"
Also, the field count must also match the values count.
Also, the field count must also match the values count.
Re: lil question
he did explain but the guy isn't really a teacher just beeing pulled out of the daylywork life and beeing put infront of a class and has to exlain it while he doesn't know how. i got the the exact lesson of what he explaint but he didn't really got into it much or told us how to use it.
the user has to be Projecten forgot to change that part hmm and i also for the _ in the last name for the rest is it alright like that? \
the user has to be Projecten forgot to change that part hmm and i also for the _ in the last name for the rest is it alright like that? \
Re: lil question
In my opinion you should find some introductory tutorials, learn some of this stuff and savvy up, and teach the class for him
A nother good starting point would be installing phpmyadmin, it provides a GUI and generates queries for you. You can either copy & paste their queries or learn from them as you use the UI tool to do the database operations for you
Re: lil question
the database i use for it is an phpadmin db but my teacher is beeing an ass and make us do it this way to make the table etc. wel if i can't get it working i'll send the unfinished one to him and ask him next week how to do it. as i only see him on mondays :S
Re: lil question
If you use phpmyadmin it shows you the queries it runs, you could copy and paste those and modify them as need be
Re: lil question
Lol, why are we doing this kids homework for him?? Sounds like someone was sleeping in class -- my favorite pastime!
Re: lil question
exactly 