Jump to content

MDanz

Members
  • Posts

    728
  • Joined

  • Last visited

Everything posted by MDanz

  1. the following should return 1 row $search= "Timothy"; $query4 = mysql_query("SELECT * FROM test1, test2, combination WHERE test1.IDONE = `combination`.IDONE AND test2.IDTWO = combination.IDTWO AND test1.NAME LIKE '%$search%'",$this->connect) or die(mysql_error()); instead it returns zero. the query should take values from all three tables according to the where clause. in short to describe the table structure. 3 tables(test1, test2, combination) test1 has primary key IDONE, test2 has primary key IDTWO combination looks like this CREATE TABLE `combination` ( IDONE int( NOT NULL, IDTWO varchar(11) NOT NULL, INFO char(200) NOT NULL, INDEX (IDONE, IDTWO), PRIMARY KEY (IDONE,IDTWO), FOREIGN KEY (IDTWO) REFERENCES `test2` (IDTWO) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (IDONE) REFERENCES `test1` (IDONE) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=INNODB; i havent done the relational database wrong.. there is no mysql_errors either. any idea?
  2. i knew about the img tag.. i did this.. while($row = mysql_fetch_assoc($query4)) { $id = $row['ID']; $thename = $row['theNAME']; $thephoto = $row['thePHOTO']; echo "<img src='$thephoto' alt='photo' />"; } where do i put header('Content-type:image/jpeg');
  3. $thephoto = $row['thePHOTO']; in mysql thephoto is BLOB file type and stores an image i want to display the image as an avatar, in a while loop. while($row = mysql_fetch_assoc($query4)) { $id = $row['ID']; $thename = $row['theNAME']; $thephoto = $row['thePHOTO']; } how do i make blob readable and then display as an image?
  4. ok after some changing up i get this message Notice: Undefined index: student.SID in C:\xampp\test.php on line 62 Notice: Undefined index: course.CID in C:\xampp\test.php on line 63 $sid = $row['student.SID']; $cid = $row['course.CID']; here is the query $query2 = mysql_query("SELECT student.SID, course.CID FROM student, course, `student-course` WHERE student.SID = `student-course`.SID AND course.CID = `student-course`.CID AND GRADE BETWEEN $beginning AND $grade",$this->connect)or die(mysql_error()); this is a relational database...can you see whats wrong?
  5. Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\test.php on line 58 line 58 is the where the while loop starts.. what have i done wrong? $query2 = mysql_query("SELECT student.SID, course.CID FROM student, course WHERE student.SID = `student-course.SID` AND course.CID = `student-course.CID` AND GRADE BETWEEN $beginning AND $grade",$this->connect); while($row = mysql_fetch_assoc($query2)) { $sid = $row['student.SID']; $cid = $row['course.CID']; echo "$sid-$cid"; }
  6. is this calling a function or calling a method? what's the difference? $thedatabase->opendb(); class Database { function opendb() { $this->connect= mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$this->connect) { die (mysql_error()); } $db_select = mysql_select_db(DB_NAME, $this->connect); if(!$db_select) { die (mysql_error()); } } }
  7. actually the page is taking long to load because of the code... is it because i am repeatedly calling the method?
  8. I want to loop the below code until $grade=80, is the code below correct <?php include "grade.php"; $getgrade = new Grade(); // create an instance of the class(Grade) echo "<ul id='navigation'>"; for($grade=0;$grade<80;$grade+10){ $max = $grade+9; //get max grade for that grading bracket, e.g. 10-19% echo "<li><a href='#'>$grade-$max%</a> <ul><li>"; $getgrade->results($grade+9); // call the method(results) in grade.php echo "</li></ul> </li>"; } echo "</ul>"; ?> the page isn't loading when i try it so i'm guessing i got it wrong..
  9. can't i put backticks around the table name or apostrophes?
  10. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-course WHERE GRADE BETWEEN 0 AND 9' at line 1 class Grade { public function results($grade) { $beginning = $grade-9; $query = mysql_query("SELECT * FROM student-course WHERE GRADE BETWEEN $beginning AND $grade") or die(mysql_error()); while($row = mysql_fetch_assoc($query)) { $sid = $row['SID']; $cid = $row['CID']; echo "<li>$sid-$cid</li>"; } } } ?> why am i getting this error?
  11. 4get found the problem.. thx
  12. thx... it says "Column count doesn't match value count at row 1" ..do you know what that means?
  13. form <form action="<?php $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" method="post" ><input type="file" name="photo" value="" size="30" /><input type="submit" name="ssubmit" value="Submit" /></form> $tmpname = $_FILES['photo']['tmp_name']; $readphoto = fopen($tmpname, 'r'); $photo = fread($readphoto, filesize($tmpname)); $photo = addslashes($photo); fclose($readphoto); $query = "INSERT INTO student (PHOTO) ". "VALUES ('$photo')"; mysql_query($query) or die('Error, query failed.'); echo "Student information submitted."; i keep getting "Error, query failed"... what did i do wrong?
  14. for the below code, what does the get_magic_quotes_gpc part mean?... in simple terms $photoname = $_FILES['photo']['name']; if(!get_magic_quotes_gpc()) { $photoname = addslashes($photoname); }
  15. CREATE TABLE Student{SID int( 8 ) NOT NULL AUTO_INCREMENT , SNAME varchar( 200 ) NOT NULL default, ADDRESS text NOT NULL default, POST_CODE varchar( 10 ) NOT NULL default, PHOTO mediumblob NOT NULL default, PRIMARY KEY ( SID ) } ENGINE = INNODB; for this i get this error #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '{ SID int( NOT NULL auto_increment, SNAME varchar(200) NOT NULL default, ' at line 1
  16. when i put this in phpmyadmin i get errors... can anyone look over it and find a mistake.. CREATE TABLE Student { SID int NOT NULL default, SNAME varchar(200) NOT NULL default, ADDRESS text NOT NULL default, POST_CODE varchar(10) NOT NULL default, PHOTO mediumblob NOT NULL default, Primary Key (SID) } ENGINE=INNODB CREATE TABLE Course { CID int NOT NULL default, CNAME varchar(200) NOT NULL default, DEPARTMENT text NOT NULL default, Primary Key (CID) } ENGINE=INNODB CREATE TABLE Student-Course { SID int NOT NULL default, CID int NOT NULL default, GRADE varchar(200) NOT NULL default, COMMENTS text NOT NULL default, Primary Key (SID,CID), FOREIGN KEY (CID) REFERENCES Course (CID) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (SID) REFERENCES Student (SID) ON UPDATE CASCADE ON DELETE CASCADE } ENGINE=INNODB
  17. whne i do this i get results $construct = "SELECT * FROM Entries WHERE hec LIKE '%$search%' ORDER BY date DESC"; when i do thisi get no results $construct = "SELECT * FROM Entries WHERE (hec OR other) LIKE '%$search%' ORDER BY date DESC"; what's the problem?
  18. how do i loop this so that the option in the drop down list loop. i tried this but get an error <select name="age"><?php for ($i=10; $i<71; $i++ { echo "<option value='$i'>$i</option>"; } ?></select>
  19. whats the difference between the two? Could i have an example of a functional and non-functional user requirement?
  20. I'm making a website and i'm on the design phase(Application Specification). this is a requirment. Describes the functionality of the application from the point of view of the user with no technical detail included. Now so far for that i have done a navigation map(told us to do one), flow chart and also a paragraph in the user point of view of how the website works. Can anyone think of any thing else to add that describes the functionality of a website?
  21. is there a way to get the $image width?... the $image is not on my server so i cant use getimagesize().. e.g. $image = http://www.example.com/picture.jpg how do i get the width?
  22. is there a way to get the $image width?... the $image is not on my server so i cant use getimagesize()..
×
×
  • 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.