Jump to content

Problem with code


Recommended Posts

There's a problem with a semicolon in our code on line 18 and we can't find out where it is supposed to be. We coppied the code from a book, and they don't have one. Please help us. Thanks :)

[code]<!-- Program: mysql_send.php
Desc: PHP program that sends an SQL query to the
MySQL server and displays the results.
<head><title>SQL Query Sender</title></head>
/* Section that executes query */
if(@$_GET[‘form’] == “yes”)
{ mysql_connect($host,$user,$password);
$query = stripSlashes($_POST[‘query’]);
$result = mysql_query($query);
echo “Database Selected: <b>{$_POST[‘database’]}</b><br>
Query: <b>$query</b><h3>Results</h3><hr>”;
if($result == 0)
echo “<b>Error “.mysql_errno().”: “.mysql_error().
elseif (@mysql_num_rows($result) == 0)
echo(“<b>Query completed. No results returned.
echo “<table border=’1’>
for($i = 0;$i < mysql_num_fields($result);$i++)
echo “<th>”.mysql_field_name($result,$i).
echo “ </tr>
for ($i = 0; $i < mysql_num_rows($result); $i++)
echo “<tr>”;
$row = mysql_fetch_row($result);
for($j = 0;$j<mysql_num_fields($result);$j++)
echo(“<td>” . $row[$j] . “</td>”);
echo “</tr>”;
echo “</tbody>
} //end else
echo “
<form action=\”{$_SERVER[‘PHP_SELF’]}\” method=\”POST\”>
<input type=’hidden’ name=’query’ value=’$query’>
<input type=’hidden’ name=’database’
<input type=’submit’ name=\”queryButton\”
value=\”New Query\”>
<input type=’submit’ name=\”queryButton\”
value=\”Edit Query\”>
} // endif form=yes
if (@$_POST[‘queryButton’] != “Edit Query”)
$query = “ “;
<form action=”<?php echo $_SERVER[‘PHP_SELF’] ?>?form=yes”
<td align=right><b>Type in database name</b></td>
<td><input type=”text” name=”database”
value=<?php echo @$_POST[‘database’] ?> ></td>
<td align=”right” valign=”top”>
<b>Type in SQL query</b></td>
<td><textarea name=”query” cols=”60”
rows=”10”><?php echo $query ?></textarea>
<td colspan=”2” align=”center”><input type=”submit”
value=”Submit Query”></td>
Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 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.