Jump to content

Catling

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Catling's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well im choosing option Author/Actress from the menu bar on my website and then entering Hugh Grant in to my search text box. So im reading the menu bar in with variable $searchtype and reading the text box in with $searchterm. Just to note I have placed Hugh Grants record in my database So I think im selecting all from my actor table where read in $searchtype LIKE to read in a string $searchterm i.e $query = "SELECT * FROM `actor` WHERE $searchtype LIKE '%$searchterm%'''; where am i going wrong? please help
  2. Thanks very much. I now have the following error again: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\apps\phpmyadmin2.11.5\search.php on line 44 I don't understand what this is? please help
  3. I think I have a problem with my query. The syntax in my book must be different from the version of SQL im using, could you assist me with this query please? I think it must be something to do with single and double quotations $query = 'SELECT * FROM actor WHERE ".$searchtype." LIKE '%".$searchterm."%''; Any help would be much appreciated
  4. it is movidedatabase? Because that is the name of my database. Im guessing I cant just look in the whole database and actually have to point to a particular table?
  5. Ive fixed that. Now i get: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\apps\phpmyadmin2.11.5\search.php on line 44 Line 44 is: $num_results = mysql_num_rows($result); I know mysql_num_rows() needs to be used with a SELECT statement, which I have done in my query. Im confused as to what it might be??? please help
  6. I've tried it and it just ignores the line and move onto the next line which produces the same error as the line above.
  7. wont it just output the whole thing <td>{$row[Forename]}</td>; as a string because its in quotations?
  8. Thanks for your help guys. I think my book from the library is out of date I now get an error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\wamp\apps\phpmyadmin2.11.5\search.php on line 61(highlighted the line below) while($row = MySQL_fetch_array($result)) { echo "<td>{$row['Forename']}</td>"; echo "<td>{$row['Surname']}</td>"; echo "<td>{$row['Age']}</td>"; echo "<td>{$row['Date_of_Birth']}</td>"; echo "<td>{$row['Nationality']}</td>"; echo "<td>{$row['Character_Names']}</td>"; echo "<td>{$row['Photo']}</td></tr>"; } echo "</table>"; Any advice?
  9. I am having trouble with my script. I am trying to make a search for a particular actor that is typed into my text area. e.g like searching hugh grant on imdb.com. Im trying to read in the input from the drop down search term and the search bar. My Problem: My script will execute but it wont go past the point in my code (Highlighted the point in bold below) that tests to see if I have selected a search type from the drop down menu and entered a string in the searchterm text box. It simply just echos "Please enter search details. Please go back and try again". I just can not understand why it wont read in my input??????? heres my script: <html> <body> <?php //create short variable names $searchtype=$HTTP_POST_VARS['searchtype']; $searchterm=$HTTP_POST_VARS['searchterm']; // cut out the whitespace $searchterm= trim($searchterm); // testing to see the user entered a search type and a search term if (!$searchtype || !$searchterm) { echo 'Please enter search details. Please go back and try again'; exit; } // slashes out control characters $searchtype= addslashes($searchtype); $searchterm= addslashes($searchterm); // make connection to database $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; @ $db = mysql_pconnect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); if (!$db) { echo 'Error: Could not connect to Database. Please Try Again'; exit; } $db=mysql_select_db('moviedatabase') or die("could not connect ".mysql_error); $query = "SELECT * FROM moviedatabase WHERE ".$searchtype." LIKE '%".$searchterm."%'"; $result = mysql_query($query); $num_results = mysql_num_rows($result); echo '<p> Number of Results found: '.$num_results.' </p>'; // loop to output number of results to the screen for ($i=0; $i <$num_results; $i++) { // test to see that the search type is Actor/Actress if ($searchtype == "Actor/Actress") { echo "<table border=1 >"; echo "<tr><td> Actor ID</td><td>Forename</td><td>Surname</td>><td>Age</td><td>Date of Birth</td><td>Nationality</td><td>Character Names</td><td>Photo</td></tr>"; while($row = MySQL_fetch_array($result)) { echo "<td>{$row['Actor_ID']}</td>"; echo "<td>{$row['Forename']}</td>"; echo "<td>{$row['Surname']}</td>"; echo "<td>{$row['Age']}</td>"; echo "<td>{$row['Date_of_Birth']}</td>"; echo "<td>{$row['Nationality']}</td>"; echo "<td>{$row['Character_Names']}</td>"; echo "<td>{$row['Photo']}</td></tr>"; } echo "</table>"; //else ( echo ' No results Found: Please go back and try again') } } ?> </body> </html> Any help would be much appreciated
×
×
  • 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.