mikosiko
Members-
Posts
1,327 -
Joined
-
Last visited
-
Days Won
1
Everything posted by mikosiko
-
in your code you are getting only the first record... here: if ($result && mysql_num_rows($result) > 0) { $query_data=mysql_fetch_array($result); $inclTerror= (float) $query_data["incl_Terror"]; $legal= (float) $query_data["legal_exp"]; $liability= (float) $query_data["liability"]; } you need: 1) Select the type field in your select 2) Loop the resultset with a WHILE and display your table in the loop
-
[OT]: what a great complement/definition to mix with your username!! [/OT]
-
and where are you defining $insType ? Edit: Maq beat me
-
ditto... that explain and close the topic
-
why? :'( funny.... I know exactly when/why to use the backticks... the question was aimed for you to explain why you were recommending to do that when was totally unnecessary...
-
usually could means: - The user (topshed in this case) exist but the provided password is incorrect (or null); or - The user topshed doesn't have the proper GRANTS for the selected DB.
-
green, wet behind the ears new to web programming needs help
mikosiko replied to johnleaf's topic in MySQL Help
well... Merlin the magician with his lustrous Cristal ball doesn't login here to often ... so post your table, the code that you have already and your specific questions and someone sure will help welcome -
if this is your current code: $sql = "SELECT sid FROM STUDENTS"; $result1 = $db1->getResult($sql); <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> Choose student ID: <select name = "sid"> <?php while ($row = mysql_fetch_array($result)) echo "<option value='{$row['SID']}'>{$row['SID']}</option>"; ?> then you have there another clear error.... result1 <> result
-
without look your whole code (maybe is more errors there).. but this lines contain a obvious error $sql = "SELECT SID FROM STUDENTS"; $result = $db1->getResult($sql); $sql = "SELECT CID FROM COURSES"; $result = $db1->getResult($sql); Hint: I will not name my two dogs "dummer".... they will be really confused if I call them
-
Seriously... and with all due respect... but you better have to look/study the code that you have and analyze it before to try to run.... some clues: This code is garbage: $numofrows = $db1->insert_student_course($sql = "SELECT STUDENTS.SID, STUDENTS.SNAME, STUDENTS.PHOTO, STUDENT_COURSE.CID, STUDENT_COURSE.GRADE FROM STUDENTS, STUDENT_COURSE WHERE (STUDENTS.SID LIKE '$SID%'); SELECT COURSES.CID, COURSES.CNAME, STUDENT_COURSE.SID, STUDENT_COURSE.GRADE FROM COURSES, STUDENT_COURSE WHERE (COURSES.CID LIKE '$CID%'); ", $grade, $comments); why?... simple... just look your function definition: function insert_student_course($cid, $sid, $grade, $comments) you will notice that it is expecting 4 arguments... CID, SID, GRADE and COMMENTS ... right? you are getting GRADE & COMMENTS using POST ($_POST['grade'] and $_POST['comments']) , therefore in the code below you need to provide CID & SID in some way.... do you think that those SELECT provide those values to the function? $numofrows = $db1->insert_student_course($sql = "SELECT STUDENTS.SID, STUDENTS.SNAME, STUDENTS.PHOTO, STUDENT_COURSE.CID, STUDENT_COURSE.GRADE FROM STUDENTS, STUDENT_COURSE WHERE (STUDENTS.SID LIKE '$SID%'); SELECT COURSES.CID, COURSES.CNAME, STUDENT_COURSE.SID, STUDENT_COURSE.GRADE FROM COURSES, STUDENT_COURSE WHERE (COURSES.CID LIKE '$CID%'); ", $grade, $comments); ... so that code should looks like: $numofrows = $db1->insert_student_course($SID, $CID, $grade, $comments); assuming that you are getting $CID and $SID values in some place. And last but not least.... in your function you have your CID and SID values transposed .. it should be: function insert_student_course($sid, $cid, $grade, $comments) and inside of it also transpose the sid, cid position in the VALUES arguments for the INSERT clause hope this help
-
the post is duplicated or you are using 2 identities? or are you both working in the same project? http://www.phpfreaks.com/forums/mysql-help/missing-foreign-key/ post what error are you getting... in details
-
Just try to follow this: - In your table student-courses the fields SID and CID must be the same type/length that the corresponding ones in tables students and courses. - In your table student-courses set your Indexes KEY `SID` and KEY `CID` as a BTREE type. - after that try to create your foreign keys. This script work perfectly for me (in case you want to try it to recreate the table.. WARNING: It will delete all your data in that table!!) : DROP TABLE IF `student_course`; CREATE TABLE `student_course` ( `SID` int( NOT NULL, `CID` int(11) NOT NULL, `GRADE` varchar(1) NOT NULL, `COMMENTS` varchar(50) NOT NULL, KEY `Index_1` (`SID`), KEY `Index_2` (`CID`), CONSTRAINT `FK_student_course_2` FOREIGN KEY (`CID`) REFERENCES `courses` (`cid`) ON DELETE RESTRICT, CONSTRAINT `FK_student_course_1` FOREIGN KEY (`SID`) REFERENCES `students` (`sid`) ON DELETE RESTRICT ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-
@luciform : - Just use the auto-increment, the way that it behave is the right way. - You better rename your "index" field... "index is a MYSQL reserved word... otherwise you will need to enclose it in backticks every time you need to use it.
-
what is `mydatabase` ... a variable?.... why you are using backticks on it?
-
try: SELECT title, body, picdescription, piclink, date_format(date, '%D %M %Y' ) as convDate FROM news LEFT JOIN newspic ON newspic.newsid = news.id WHERE news.id = $nid assuming that newspic.newsid is the foreign key to news (newspic.newsid = news.id).... otherwise replace with the right field holding the relationship.
-
incorrect syntax http://dev.mysql.com/doc/refman/5.0/en/select.html and related http://dev.mysql.com/doc/refman/5.0/en/expressions.html .... is not a correct expresion
-
No idea why this query is not working to update my database. Any help?
mikosiko replied to Lexicon's topic in MySQL Help
don't use quotes to surround your field names also... use SET only one time SET kid1 = 'girl', kid2 = 'girl', kid3 = 'boy' -
I did ask for "MYSQL QUERY BROWSER" ... and the code that you posted works on it without any problem.
-
Returning multiple rows from LOOP inside procedure
mikosiko replied to the_oliver's topic in MySQL Help
Do you have any reason to do that in a procedure?... why not use directly just one select joining both tables? -
I'm assuming that you mean 'MYSQL Query Browser'.... in that case probably you opened a 'ResultSet Tab' and wrote your 2 lines of code... right? in that case.... put your cursor in the first line (SET @dnr=3;) and select 'Execute' ... and after that position your cursor in the second line and execute it.... that should work.
-
I just don t see how to link fileds of one table to another table
mikosiko replied to franklos's topic in MySQL Help
Of course.... INSERT .... SELECT... manually a hell of a job?... sure.... using ^^^ maybe 2 minutes max. Sure.... -
Self Updating MySQL database from mirrored database
mikosiko replied to kaisaj's topic in MySQL Help
and query the Time Matters Db (MS SQL 2005 or 2008) directly is not an option?... is any reason why you need to export the data to another DB? If not possible, and you know the Data Model of Time Matters and have the username/password to access the data I don't see too much difficulties implementing something like you want. general steps: - Make an script that query the TM DB and extract the data. - Move that data (insert/update/delete) to your other DB - Automatize that process using Scheduler if Windows or Cron if Unix -
I just don t see how to link fileds of one table to another table
mikosiko replied to franklos's topic in MySQL Help
Yes Yes No... only the previous one is necessary Something like that -
I just don t see how to link fileds of one table to another table
mikosiko replied to franklos's topic in MySQL Help
That was obvious .... but I'm trying to help you to have a better DB design.... your design is not good. but answering your question... yes it is possible to JOIN both tables. examples here: http://dev.mysql.com/doc/refman/5.0/en/join.html But parodying someone that I don't remember : "With your model, do that under your own risk... you have been Warned"