<html>
<head>
<title>PHP SQL Code Tester</title>
</head>
<body>
<?php
$user="php";
$host="localhost";
$password="php";
mysql_connect($host, $user, $password);
mysql_select_db($database);
$query=stripSlashes($query);
$result=mysql_query($query);
?>
Results of query <B><?php echo($query); ?></b><hr>
<?php
if ($result == 0):
echo("<B>Error " . mysql_errno() . ": " . mysql_error() . "</b>");
elseif (mysql_num_rows($result) == 0):
echo("<b>Query executed successfully!</b>");
else:
?>
<TABLE BORDER = 1>
<THEAD>
<TR>
<?php
for($i=0; $i < mysql_num_fields($result); $i++) {
echo("<TH>" . mysql_field_name($result, $i) . "</TH>");
}
?>
</TR>
</THEAD>
<TBODY>
<?php
for($i=0; $i < mysql_num_rows($result); $i++) {
echo("<TR>");
$row_array=mysql_fetch_row($result);
for ($j=0; $j < mysql_num_fields($result); $j++) {
echo("<TD>" . $row_array[$j] . "</TD>");
}
echo("</TR>");
}
?>
</TBODY>
</TABLE>
<?php
endif
?>
<HR><BR>
<FORM ACTION=query.php METHOD=POST>
<INPUT TYPE = SUBMIT VALUE="New query">
</FORM>
</BODY>
</html>
Above is the code
I'm getting undefined variable for the below two commands, i hope you could help me with it
mysql_select_db($database);
$query=stripSlashes($query);
And I got the warning below
Warning: mysql_connect(): Access denied for user: 'php@localhost' (Using password: YES) in C:\Program Files\Apache Group\Apache2\htdocs\mysql_test.php on line 12
for the below line
mysql_connect($host, $user, $password);
I hope you all could help me
Thankss