Welcome to WebmasterWorld Guest from 54.166.227.36

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Need a bit of help with Script error

Simple "script execution error"

     
11:28 pm on Nov 22, 2005 (gmt 0)

10+ Year Member



Hi All,

I placed the code in WebCoder and still couldn't find the error. I know it will be easy for you alll to see.
I just get a bit frustrated from these kinds of "simplistic" errors.

Thanks,
Senmar

<?
include(?.php');

// Get some data from the table.
$query = "SELECT publication_name, publication_year, url FROM news_table WHERE publication_name='$publication_name', publication_year='$publication_year', url='$url'";

$result =@mysql_query($query) or die ('Could not execute query.');

echo "<table border=1>";
echo "<tr><th>Publication Name</th><th>Publication Year</th><th>Volume Number</th><th>URL</th></tr>";

while($row = mysql_fetch_array($result))
{

// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['publication_name'];
echo "</td><td>";
echo $row['publication_year'];
echo "</td><td>";
echo $row['volume_number'];
echo "</td><td>";
echo $row['url'];
echo "</td></tr>";

echo "</table>";
}
?>
<html>
<form method="post" name="Publications" action="srch.php">
<table><tr>
<td>Publication Name:</td>
<td><input type="text" name="publication_name" size="40" maxlength="45"></td>
</tr><tr>
<td>Publication Year:</td>
<td><input type="text" name="publication_year" size="4" maxlength="4"></td>
</tr><tr>
<td>Volume Number:</td>
<td><input type="text" name="volume_number size="4" maxlength="5"></td>
</tr><tr>
<td>URL:</td>
<td><input type="text" name="url" size="60" maxlength="65"></td>
</tr>
<tr><td colspan="2" align="center">
<input type="submit" name="Publications" value="Search Database">
<input type="reset" name="reset" value="Reset"></td>
</tr></table>
</form>
</html>

12:02 am on Nov 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well the include statement looks weird
include(?.php');

If that's not it then what is the error message and what line is it on?

Tim

3:00 am on Nov 23, 2005 (gmt 0)

10+ Year Member



Hi!

I just removed the real information from the "include" statement. It contains the connect information. The error I am getting is "Can't execute query" It follows my SELECT statment.

Thanks
SenMar

3:14 am on Nov 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, well let's do a little debugging. Make these changes to view your sql statement and get some feedback on the error.

$query = "SELECT publication_name, publication_year, url FROM news_table WHERE publication_name='$publication_name', publication_year='$publication_year', url='$url'";

echo $query."<br>";

$result =@mysql_query($query) or die (mysql_errno().": ".mysql_error()."<br>");

It's probably something like a ' in one of your variables that's making it choke.

Tim

8:39 am on Nov 23, 2005 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I`m guessing the problem is the commas in your query. Try:

$query = "SELECT publication_name, publication_year, url FROM news_table WHERE publication_name='$publication_name' AND publication_year='$publication_year' AND url='$url'";

dc

 

Featured Threads

Hot Threads This Week

Hot Threads This Month