Welcome! Log In Create A New Profile

Advanced

MySQL Portfolio Questions

Posted by 35316462_Antondev 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
MySQL Portfolio Questions
May 08, 2013 01:08PM
Hi.

I am busy setting up my Database in MySQL for the portfolio.

Just to make sure, because this is bothering me.:

1. In the tutorial letter there is no indication on what TYPE we should use for each field and what length are required ? I know we should use commonsense like for text = varchar and numbers = int, but the problem is there is more than one int definition.
Can I just leave it as default with not declaring any length values, because my database will eventually not be used ? The reason why I ask is that the database the PHP source will run on eventually would be setup in a different way with fields declared a certain type and length ?

2. What Collation should we use for each field? Can we leave it also as default ?

Student Number: 78042879 (Part Time Courses)
avatar
Mac
Re: MySQL Portfolio Questions
May 08, 2013 03:17PM
1. You can use what you want, I use a db that mostly all text fields so it will take whatever you have used. auto-increment should be INT though. Of course using text fields for all is not not correct, but for marking purposes only. Where a text field will not work, a simple glance at your code will inform me of your approach.

2. Default yes
Re: MySQL Portfolio Questions
May 08, 2013 07:14PM
Thank You Mac.

Student Number: 78042879 (Part Time Courses)
Re: MySQL Portfolio Questions
May 08, 2013 11:16PM
I also had this challenge but was completely informed when i read through the prescribed text book (Beginning PHP5, Apache, MySQL Web Development). If you've got it you could take a quick read on pages 86 - 88 (Field Types).

I hope it helps.

78026962 afojonny
Re: MySQL Portfolio Questions
May 15, 2013 11:28AM
good day
im starting now with my portfolio, i know its too late but my time was very constricted sad smiley

my first question is , with regard to the admin who can mange the courses,
which table should we add the admin username and password?

should i create a table for admin users? or include it with student table and include extra field for admins?

Thank you
Re: MySQL Portfolio Questions
May 15, 2013 12:48PM
Hi. I would not worry about "User Rights" for know. You are writing it solely for a admin person. You must only use the tables provided and nothing else not even adding more fields only the fields as stipulated in the tutorial. Make sure the program works then you can look into things like "user authentication". If I where you I would rather spend the last time you have left on things like security measures(like user input) and functions than "User Authentication".

Student Number: 78042879 (Part Time Courses)
avatar Re: MySQL Portfolio Questions
May 15, 2013 12:55PM
Not sure if it is to late,but maybe you should try and ask Mac if they can change your registration to the second semester.




M.Sabah Wrote:
-------------------------------------------------------
> good day
> im starting now with my portfolio, i know its too
> late but my time was very constricted sad smiley
>
> my first question is , with regard to the admin
> who can mange the courses,
> which table should we add the admin username and
> password?
>
> should i create a table for admin users? or
> include it with student table and include extra
> field for admins?
>
> Thank you
Re: MySQL Portfolio Questions
May 15, 2013 01:08PM
Wow, such a short time. Please speak to Mac for an objective view on the way to go. That's not to say you can't make the final date; "35316462_Antondev" gave a good one!

All the best.

78026962 afojonny
Re: MySQL Portfolio Questions
May 15, 2013 01:10PM
Thank you for reply.
i just spoke with him now.
i think i can make it just wish for me the luck smiling smiley

Thank you
Mohammed
Re: MySQL Portfolio Questions
May 15, 2013 01:20PM
Okay then.

All the best Mohammed!smile

78026962 afojonny
Re: MySQL Portfolio Questions
May 16, 2013 09:21AM
Good morning to very one.
just want to ask about the student reg form.
how i can make the date of birth field?

should we do it as pop up with calendar and user select his birthdate? not not sure how to make it if yes?

any idea can help me please?
Re: MySQL Portfolio Questions
May 16, 2013 09:54AM
you are free to use any method. I used a pop up calendar because I didn't want users to supply me with different formats.
Re: MySQL Portfolio Questions
May 16, 2013 11:48AM
Hello
im busy with student reg form and having a problem.
if i submit text through Surname, Initials, First Name, Title, Maiden Surname and gender, its work fine.
but after gender if i submit text, it will not go through ? if i submit numbers, its go through?
if i submit on the language now with number its work but inf i put text, it will not go through



plsssss help confused smiley






Language: PHP
<?PHP // include "includes/config.php";   //$sname = ""; //$init= ""; //$msname= ""; //$errorMessage = ""; //$num_rows = 0; $Mr = ';Mr';; $Mrs = ';Mrs';; $Miss = ';Miss';; $Ms = ';Ms';; //$dob = date("Y-m-d H:i:s");     function quote_smart($value, $handle) {   if (get_magic_quotes_gpc()) { $value = stripslashes($value); }   if (!is_numeric($value)) { $value = "';" . mysql_real_escape_string($value, $handle) . "';"; } return $value; }   if ($_SERVER[';REQUEST_METHOD';] == ';POST';){   //==================================================================== // GET THE CHOSEN U AND P, AND CHECK IT FOR DANGEROUS CHARCTERS //==================================================================== $sname = $_POST[';sname';]; $init = $_POST[';init';]; $fname = $_POST[';fname';]; $title= $_POST[';title';]; $msname= $_POST[';msname';]; $gen= $_POST[';gen';]; $lang= $_POST[';lang';]; /*$idno= $_POST[';idno';]; $telh= $_POST[';telh';]; $telw= $_POST[';telw';]; $cel= $_POST[';cel';]; $fax= $_POST[';fax';]; $email= $_POST[';email';]; $address= $_POST[';address';]; //$contact_flag = $_POST[';contact_flag ';];*/   $sname = htmlspecialchars($sname); $init = htmlspecialchars($init); $fname = htmlspecialchars($fname); $title = htmlspecialchars($title); $msname = htmlspecialchars($msname); $gen = htmlspecialchars($gen); $lang = htmlspecialchars($lang); /*$idno = htmlspecialchars($idno); $telh = htmlspecialchars($telh); $telw= htmlspecialchars($telw); $cel = htmlspecialchars($cel); $fax = htmlspecialchars($fax); $email = htmlspecialchars($email); $address = htmlspecialchars($address); $contact_flag = htmlspecialchars($contact_flag ); */ //==================================================================== // CHECK TO SEE IF U AND P ARE OF THE CORRECT LENGTH // A MALICIOUS USER MIGHT TRY TO PASS A STRING THAT IS TOO LONG // if no errors occur, then $errorMessage will be blank //====================================================================   $uLength = strlen($sname); $eLength = strlen($init);   if ($uLength >= 3 && $uLength <= 18) { $errorMessage = ""; } else { $errorMessage = $errorMessage . "Username must be between 3 and 50 characters" . "<BR>"; }       if ($eLength >= 1 && $eLength <= 18) { $errorMessage = ""; } else { $errorMessage = $errorMessage . "Password must be between 8 and 16 characters" . "<BR>"; }     //test to see if $errorMessage is blank //if it is, then we can go ahead with the rest of the code //if it';s not, we can display the error   //==================================================================== // Write to the database //==================================================================== if ($errorMessage == "") {   $user_name = "root"; $pass_word = ""; $database = "registration"; $server = "127.0.0.1";   $db_handle = mysql_connect($server, $user_name, $pass_word); $db_found = mysql_select_db($database, $db_handle);   if ($db_found) {   $sname = quote_smart($sname, $db_handle); $init= quote_smart($init, $db_handle); $fname= quote_smart($fname, $db_handle); $title= quote_smart($title, $db_handle); $msname= quote_smart($msname, $db_handle); $gen= quote_smart($gen, $db_handle);   /*$address= quote_smart($address, $db_handle); $email= quote_smart($email, $db_handle); $fax= quote_smart($fax, $db_handle); $cel= quote_smart($cel, $db_handle); $telw= quote_smart($telw, $db_handle); $cel= quote_smart($cel, $db_handle); $fax= quote_smart($fax, $db_handle); $email= quote_smart($email, $db_handle); $address= quote_smart($address, $db_handle); $contact_flag = quote_smart($contact_flag , $db_handle);*/           //==================================================================== // CHECK THAT THE USERNAME IS NOT TAKEN //====================================================================   $SQL = "SELECT * FROM student WHERE sname = $sname"; $result = mysql_query($SQL); $num_rows = mysql_num_rows($result);   if ($num_rows > 0) { $errorMessage = "Username already taken"; }   else {   $SQL = "INSERT INTO student (sname, init, fname, title, msname, gen, lang) VALUES ($sname, $init, $fname, $title, $msname, $gen, $lang)"; /////////////////////// addddddddddddd $result = mysql_query($SQL); // $result = mysql_query( $sql) or die(mysql_error());     mysql_close($db_handle);   //================================================================================= // START THE SESSION AND PUT SOMETHING INTO THE SESSION VARIABLE CALLED login // SEND USER TO A DIFFERENT PAGE AFTER SIGN UP //=================================================================================   //session_start(); //$_SESSION[';login';] = "1";   header ("Location: page1.php");   }   } else { $errorMessage = "Database Not Found"; }         }   }     ?>   <html> <head> <title>Basic Login Script</title> <link rel="stylesheet" type="text/css" href="css.css">     </head> <body>     <FORM NAME ="form1" METHOD ="POST" ACTION ="student_reg.php">   Surname: <INPUT TYPE = ';TEXT'; Name =';sname'; value="<?PHP print $sname;?>" maxlength="20"><br> Initials: <INPUT TYPE = ';TEXT'; Name =';init'; value="<?PHP print $init;?>" maxlength="16"><br> First Name: <INPUT TYPE = ';TEXT'; Name =';fname'; value="<?PHP print $fname;?>" maxlength="16"><br> Title: <select name="title"> <option value="<?PHP print $Mr;?>">Mr</option> <option value="<?PHP print $Mrs;?>">Mrs</option> <option value="<?PHP print $Miss;?>">Miss</option> <option value="<?PHP print $Ms;?>">Ms</option> </select><br> Maiden Surname: <INPUT TYPE = ';TEXT'; Name =';msname'; value="<?PHP print $msname;?>" maxlength="16"><br> gender: <INPUT TYPE = ';TEXT'; Name =';gen'; value="<?PHP print $gen;?>" maxlength="16"><br> language: <INPUT TYPE = ';TEXT'; Name =';lang'; value="<?PHP print $lang;?>" maxlength="16"><br>                 <label> <input type="submit" name="button" id="button" value="Submit"> </label> </FORM> <P> <?PHP print $errorMessage;?>   </body> </html>
Re: MySQL Portfolio Questions
May 16, 2013 12:12PM
77911997 Wrote:
-------------------------------------------------------
> you are free to use any method. I used a pop up
> calendar because I didn't want users to supply me
> with different formats.

Hi. I also thought of using a popup calender, but what if the "type" in Mac's DB is not a "date type" ? Even if it is a date-data-type what format is the date as our programs will be run against a database that is allready populated with data ? Meaning is it D-M-Y or Y-M-D ? Can we savely assume it is in the default date-date-type format ?

Student Number: 78042879 (Part Time Courses)
Re: MySQL Portfolio Questions
May 16, 2013 01:15PM
i found the problem, it was in query written
Re: MySQL Portfolio Questions
May 16, 2013 01:39PM
if Mac has his date column as text or varchar, then it can take anything. your calendar will send it as a date format to your Database... so if YOU have your column as date type, that can not take text.

in any case Mac is a very experience lecturer... he marks the code.

Personally I am very protective of my database, if I can control it, I don't let users filter information. eg if its a province column, you can end up with KZN, Kwa-Zulu Natal or Kwazulu-Natal. in cases like that I simple do a drop down.

same thing with dates: you might end up with 16 June 2013 or 16 Jun 2013 or 16-06-2013. I would rather control it to whatever format I want.

but hey feel free to do what you are comfortable with.
Re: MySQL Portfolio Questions
May 16, 2013 02:10PM
77911997 Wrote:
-------------------------------------------------------
> if Mac has his date column as text or varchar,
> then it can take anything. your calendar will send
> it as a date format to your Database... so if YOU
> have your column as date type, that can not take
> text.
>
> in any case Mac is a very experience lecturer...
> he marks the code.
>
> Personally I am very protective of my database, if
> I can control it, I don't let users filter
> information. eg if its a province column, you can
> end up with KZN, Kwa-Zulu Natal or Kwazulu-Natal.
> in cases like that I simple do a drop down.
>
> same thing with dates: you might end up with 16
> June 2013 or 16 Jun 2013 or 16-06-2013. I would
> rather control it to whatever format I want.
>
> but hey feel free to do what you are comfortable
> with.

Hi, but that is the point. If your're date format is diffirent from Mac's DB then it is not going to display correctly in your student_man.php page, because he will run it against a database allready filled with data. He might use Y-M-D where you issue D-M-Y. Imaging his Y-M-D comes back into your format of D-M-Y ?

Student Number: 78042879 (Part Time Courses)
Re: MySQL Portfolio Questions
May 16, 2013 02:25PM
mac can either set DOB column to be text or date.

tell me which date format will boom-out if you sending it to a date-data type field?
Re: MySQL Portfolio Questions
May 16, 2013 02:37PM
77911997 Wrote:
-------------------------------------------------------
> mac can either set DOB column to be text or date.
>
>
> tell me which date format will boom-out if you
> sending it to a date-data type field?

If you pull the date-field-data-type into a form to edit it. Say it returns as Y-M-D to the form and your calender or query is setup to store it as D-M-Y.

Meaning if the "retrieved data" is displayed in your form as 1980-02-03 and your form, query or calender resubmits the data as 19-02-03[D-M-Y].

Student Number: 78042879 (Part Time Courses)
Re: MySQL Portfolio Questions
May 16, 2013 03:55PM
correct me if im wrong, most DBMS will have Y-M-D format if u use date field.
Re: MySQL Portfolio Questions
May 16, 2013 03:57PM
anyway I was just saying my personal preference. I you prefer a user inputting, than go with that.

I was just advising, I am not saying that is what you should do.
Re: MySQL Portfolio Questions
May 16, 2013 04:12PM
I really dont think it is going to matter. It is not like Mac is going to mark you on how his data looks in your script (or how your script puts data into his Dcool smiley.
He is going to mark your ability of being able to put data into a DB, pull it out again and if need be, change it.

Glen
avatar
Mac
Re: MySQL Portfolio Questions
May 16, 2013 04:52PM
Glen is 100% correct. I run the app, and when something does not work, I check the code. I will know when the type of field (for example) is a problem.

Then I check the code on it's own.

That said, and I have repeated this over and over - Do not send me code that is clearly above your "ability". I KNOW when you have exceeded your decision to enroll for this course, but equally, I KNOW when you have the ability to code/import advanced stuff, and desire a "qualification". It is easy to pick up.

It may sound like I am trying to "catch you out". No. I want you to learn (and love) PHP. No shortcuts.
Re: MySQL Portfolio Questions
May 16, 2013 06:05PM
Hi Thank You for clearing that up. Was just stressing, because there is so much effort going into this program that the last thing I want is for it not to be compatible or working on judgement day.

Student Number: 78042879 (Part Time Courses)
Re: MySQL Portfolio Questions
May 17, 2013 10:33AM
fot update courses section , it will be just to update the course name only?
im right?
Re: MySQL Portfolio Questions
May 17, 2013 11:41AM
Hey Sabah

I sure hope so because that is all that I am doing.

Glen
Re: MySQL Portfolio Questions
May 17, 2013 02:31PM
Yeah, it is. Remember you can only query cname and nothing more. So, it's just the course name you're updating.

Cheers!

78026962 afojonny
Re: MySQL Portfolio Questions
May 17, 2013 02:46PM
Thank you smiling smiley
Re: MySQL Portfolio Questions
May 18, 2013 05:48PM
77911997 Wrote:
-------------------------------------------------------
> anyway I was just saying my personal preference. I
> you prefer a user inputting, than go with that.
>
> I was just advising, I am not saying that is what
> you should do.

ARRRGG NOW I understand why it does not matter if it is a "date field" or a "varchar" or a "text field" if the php validation check is setup correctly. Sorry I was just a bit slow there. BUT Thank You anyways.

Student Number: 78042879 (Part Time Courses)
Re: MySQL Portfolio Questions
May 20, 2013 09:49AM
Good morning to every one
Im almost done with my assignment, im just busy with the user database

Now just want to confirm if I understood correctly
Now should we create a new database call user, and add a table call user?
And link the user database to registration database?

correct?

Thank you
Mohammed
Re: MySQL Portfolio Questions
May 20, 2013 10:11AM
your question is not clear. if you are almost done, how come you are still creating a database?

anyway if I got you correctly, you need to create a database, call it “registration”.

and Registration database will have 3 tables, namely “course”, “student” and “course_student”.

I hope that helps...
Re: MySQL Portfolio Questions
May 20, 2013 10:17AM
thank you for your reply
registration db done

im asking about the user (admin)
should we create a db call user for the admin, so we can allow for him to add, delete or update?

hope its celar now smiling smiley
Re: MySQL Portfolio Questions
May 20, 2013 10:18AM
this paragraph not clear for me, its on the Tutorial letter on page 15?


You then need to add a database user to the table user in the mysql database in phpMyAdmin, giving him certain rights (e.g. add, edit, delete etc), and then link this user to your registration database, in the db table.
This user and password is defined in the config file. Google for help on adding database users via phpmyadmin.
Re: MySQL Portfolio Questions
May 20, 2013 10:24AM
M.Sabah Wrote:
-------------------------------------------------------
> this paragraph not clear for me, its on the
> Tutorial letter on page 15?
>
>
> You then need to add a database user to the table
> user in the mysql database in phpMyAdmin, giving
> him certain rights (e.g. add, edit, delete etc),
> and then link this user to your registration
> database, in the db table.
> This user and password is defined in the config
> file. Google for help on adding database users via
> phpmyadmin.

You are referring to the MySQL username & password. You only need 1x user-credentials to connect to the database. in other words: You need to create a user with a password in the database and link your php to it.

Student Number: 78042879 (Part Time Courses)
Re: MySQL Portfolio Questions
May 20, 2013 11:35AM
ahhh I see what you talking about. I completely missed that part. and I didn't even code for it eye popping smiley

thank Goodness I still have 1 day atleast
Re: MySQL Portfolio Questions
May 21, 2013 01:35PM
i will upload my work before 12 at night. but is any email address we can send the work in case if the system is down?
Re: MySQL Portfolio Questions
May 21, 2013 02:05PM
files might be huge for a email. maybe a dropbox should be created for backup.
Re: MySQL Portfolio Questions
May 21, 2013 02:11PM
not , its just about 4 MB, its should be fine. its possible to have email pls
Re: MySQL Portfolio Questions
May 22, 2013 08:02AM
Good morning Mac
I sent the files last night @ 9:02 PM
and @ this morning i did realised that i did not send the DB Tables, so i sent it again with DB Tables @ 5:52AM

is that ok and accept the 2nd file pls? confused smiley
Re: MySQL Portfolio Questions
May 22, 2013 08:13AM
I thought we were not supposed to send Database SQL dumps. Mac will use his own Dump.
avatar Re: MySQL Portfolio Questions
May 22, 2013 08:26AM
No database needed. Mac is using his own DB.
Re: MySQL Portfolio Questions
May 22, 2013 08:45AM
ok, so he can still use my first file that sent yesterday smiling smiley
Re: MySQL Portfolio Questions
May 22, 2013 09:06AM
yes
Sorry, only registered users may post in this forum.

Click here to login