|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Parse Error
This code i've written keeps getting a parse error. If people could look over it and point out anything I may have missed? All the error merssage says is that it;s in line 13, but I think that's referring to the mysql_query and how I've declared variables.
All help is appreciated! ~magda~ <?php include("headerinclude.php"); ?> <head> <title>Director Search</title> </head> <body> <?php if ($submit) { // process form $directorresult = mysql_query(SELECT * FROM dvdcat_director WHERE director_surname LIKE '%$searchtext%'); if ($myrow = mysql_fetch_array($dirrectorresult)) { echo "<p>Directors that Match:</p>\n"; echo "<form><select>\n"; do { printf("<option value=".$myrow['director_id'].">".$myrow['director_firstname']." ".$myrow['director_lastname']."</option>\n"); } while ($myrow = mysql_fetch_array($directorresult)); echo "</select></form>\n"; } else { echo "Sorry, no records were found!"; } } else{ // display form ?> <h1>Enter New Series Details</h1> <form action="<?php echo $PHP_SELF?>" method="post"> <p>Director to search for: <input type="text" name="searchtext" /><input type="Submit" name="submit" value="Search" /> </form> <?php } // end if ?> </body> </html> |
|
#2
|
|||
|
|||
|
after some fiddling with the code, it's given me a new parse error. The page loads fine, but when a name is entered into the field and submitted, it gets a "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource" error. I've looked at my code a million times but I can't see what the problem is. Here's the code, please help!
(in the header include ![]() <?php // Connect to the database server $db = @mysql_connect('*login details*'); if (!$db) { die( '<p>Unable to connect to the ' . 'database server at this time.</p>' ); } // Select the database if (! @mysql_select_db('*dbname') ) { die( '<p>Unable to locate the ' . 'database at this time.</p>' ); } ?> and in the actual code: <?php include("headerinclude.php"); ?> <head> <title>Director Search</title> </head> <body> <?php if ($submit) { // process form $directorresult = mysql_query("SELECT * FROM dvdcat_director WHERE director_surname = $searchtext%", $db); if ($myrow = mysql_fetch_array($dirrectorresult)) { echo "<p>Directors that Match:</p>\n"; echo "<form><select name=\"directormatches\">\n"; do { printf("<option value=\"%s\">%s %s</option>\n", $myrow[director_id], $myrow[director_firstname], $myrow[director_surname]); } while ($myrow = mysql_fetch_array($directorresult)); echo "</select></form>\n"; } else { echo "Sorry, no records were found!"; } } else { // display form ?> <h1>Enter New Series Details</h1> <form action="<?php echo $PHP_SELF?>" method="post"> <p>Director to search for: <input type="text" name="searchtext" /><input type="Submit" name="submit" value="Search" /></p> </form> <?php } // end if ?> Please help me! i don't know what's wrong! |
|
#3
|
|||
|
|||
|
You misspelled $directorresult
|
|
#4
|
|||
|
|||
|
yes, i notices that as soon as i posted, but it didn't work. I got it working by erasing it all and starting again
thanks anyway for your help |
|
#5
|
||||
|
||||
|
there's a good chance your query isn't returning results.
on this line: $directorresult = mysql_query("SELECT * FROM dvdcat_director WHERE director_surname = $searchtext%", $db); I would change it as follows: $sql = "SELECT * FROM dvdcat_director WHERE director_surname = $searchtext%"; $directorresult = mysql_query($sql, $db) or die("ERROR ".mysql_errno().": ".mysql_error()." SQL: ".$sql); |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Parse Error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|