PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old September 18th, 2004, 10:01 AM
univinus univinus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 22 univinus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 49 sec
Reputation Power: 0
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>

Reply With Quote
  #2  
Old September 19th, 2004, 08:48 AM
univinus univinus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 22 univinus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 49 sec
Reputation Power: 0
Unhappy

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!

Reply With Quote
  #3  
Old September 19th, 2004, 11:44 AM
oyejorge oyejorge is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 25 oyejorge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 13 sec
Reputation Power: 0
You misspelled $directorresult

Reply With Quote
  #4  
Old September 19th, 2004, 08:07 PM
univinus univinus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 22 univinus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 49 sec
Reputation Power: 0
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

Reply With Quote
  #5  
Old September 20th, 2004, 10:52 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
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);

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Parse Error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway