Forum Moderators: phranque

Message Too Old, No Replies

starting a MySql Server

         

Phantom

1:09 am on Mar 17, 2004 (gmt 0)

10+ Year Member



I instaled Apache and PHP on my Windows 98 computer, and everything works fine. However, I can't get MySql to work. I start MySql with winmysqladmin.exe, and run the following script on my server.

<!-- Program Name: mysql_send.php
Description: PHP program that sends an SQL query to the
MySQL server and displays the results.
-->
<html>
<head>
<title>SQL Query Sender</title>
</head>
<body>
<?php
$user="root";
$host="localhost";
$password="";

/* Section that executes query */
if (@$form == "yes")
{
mysql_connect($host,$user,$password);
mysql_select_db($database);
$query = stripSlashes($query) ;
$result = mysql_query($query);
echo "Database Selected: <b>$database</b><br>
Query: <b>$query</b>
<h3>Results</h3>
<hr>";
if ($result == 0)
echo("<b>Error " . mysql_errno() . ": " . mysql_error() . "</b>");

elseif (@mysql_num_rows($result) == 0)
echo("<b>Query completed. No results returned.</b><br>");
else
{
echo "<table border='1'>
<thead>
<tr>";
for ($i = 0; $i < mysql_num_fields($result); $i++)
{
echo("<th>" . mysql_field_name($result,$i) . "</th>");
}
echo " </tr>
</thead>
<tbody>";
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>
</table>";
}
echo "<hr><br>
<form action=$PHP_SELF method=post>
<input type=hidden name=query value=\"$query\">
<input type=hidden name=database value=$database>
<input type=submit name=\"queryButton\" value=\"New Query\">
<input type=submit name=\"queryButton\" value=\"Edit Query\">
</form>";
unset($form);
exit();
}

/* Section that requests user input of query */
@$query = stripSlashes($query);
if (@$queryButton!= "Edit Query")
{
$database = " ";
$query = " ";
}
?>

<form action=sql.php?form=yes method="post">
<table>
<tr>
<td align="right"><b>Type in database name</b></td>
<td>
<input type=text name="database" value=<?php echo $database?> >
</td>
</tr>
<tr>
<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>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Submit Query"></td>
</tr>
</table>
</form>

</body>
</html>


(This is from PHP & MySql for Dummies by Janet Valade)
however, when I run a query through this program nothing happens. why can't I connect (I can succesfuly run through mysql.exe)

txbakers

5:02 am on Mar 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



On Windows 98 you have to manually start the mySQL server before it will work. Since W98 doesn't use services it can't find it when you boot up.

I wrote a little batch file that started the service.

Once you do that, then your script should work.

willybfriendly

5:09 am on Mar 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have MySQL running as a service on a Win98 machine with Apache and PHP (for development only of course).

If memory serves me correctly, when I set it up I couldn't get it to work because I had failed to set up a username/password, and, I had firewall issues (ZoneAlarm).

You might want to check both of those things out.

WBF

Phantom

9:19 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



I start in manualy with winmysqladmin.exe, but the script still won't work. i didn't delete the root account, so that should still work. I don't have zone alarm, and php and apache worked perfectly.
Edit: I made my own script, and it worked perfectly. The problem is with the script. Can anyone spot the problem in it? I got it from a programing book (off the cd), so there should be any typo's in it. Did the author screw up (I did find a few errors in the book, so this is possible), or is it my computer.

McKracken

12:24 am on Mar 19, 2004 (gmt 0)

10+ Year Member



Can you paste the results you get when you run this script? It is very hard to determine what is wrong with you script without that info..

One other thing, writing scripts like this is consdidered extremely unsecure.