This is a pretty simplistic database, just a load of names and the option to add your own. I'm using a file called config.php in the same dir on the server for all the functions to connect to mysql & the database.
When I try and run this script, I get a parse error on line 7, something to do with the first IF statement. I've been staring at it for an hour and cant see any problems with it - any ideas?
<html>
<head><title>Current Profile Users</title></head>
<body>
<?
include("config.php"); //calls sql_connect(), sql_accessdb() & sql_submit1()
if (isset($adduser)) {
PrintForm();
exit();
}
else {
sql_connect(); #config.php function
sql_accessdb(); #config.php function
if($submit == "SUBMIT") {
sql_submit1("profile","username","$name", "Your name was added to the database successfully."); #config.php function
$submit = NULL;
print "<a href=\"$PHP_SELF\"> <- Return to Main</a>";
exit();
}
$names = @mysql_query("SELECT username FROM profile ORDER BY username");
if(! $names) {
print "Error performing query: " . mysql_error();
exit();
}
while ($row = mysql_fetch_array("$names")) {
print $row["username"] . "<BR>";
}
//add a name
print "<a href=\"$PHP_SELF\?adduser=1\">Add a name</a>";
}
function PrintForm() {
?>
<form action="<?=$PHP_SELF?>" method="post">
<table align=center>
<tr>
<td><div align="right">Character Name:</div></td>
<td><input type="text" name="name"></td>
<td colspan="2"><div align="center">
<input type="submit" name="submit" value="SUBMIT">
</div></td>
</tr>
</table>
</form>
<?
}
?>
Cheers,