Here's the error I get:
"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\httpd\HTDOCS\admin\matches\edit_process.php on line 11"
Nevermind, that was either me not refreshing the page or something else because it doesn't work with these files.
Here's all the relevant files and commands I used... help if you can :o
mysql commands:
mysqladmin create otcwebnews
mysql - u root otcwebnews < matches.dump
matches.dump:
CREATE TABLE matches (
id INT (11) not null AUTO_INCREMENT,
opponent VARCHAR (50),
league VARCHAR (50),
score VARCHAR (50),
result VARCHAR (50),
PRIMARY KEY (id)
)
add.html:
<form name="post news" method="post" action="add_match_process.php">
Opponent: <input type="text" name="opponent">
<br>
League: <input type="text" name="league">
<br>
Score: <input type="text" name="score">
<br>
Result: <input type ="text" name="result">
<p><input type="submit" name="Submit" value="POST !"></p>
</form>
add_match_process.php:
<?php
include "config.php";
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");
$query = "INSERT INTO matches(opponent, league, score, result)
VALUES('".$_POST['opponent']."','".$_POST['league']."','".$_POST['score']."', '".$_POST['result']."')";
mysql_query($query) or die(mysql_error());
echo "Match item entered.";
mysql_close($db);
?>
edit.php:
<?php
include "config.php";
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");
echo "<b>Please click on an opponent to edit info: </b><BR>";
$query = "SELECT id, opponent FROM matches";
$result = mysql_query($query);
while($r=mysql_fetch_array($result))
{
$id=$r["id"];
$opponent=$r["opponent"];
echo "<A HREF=\"edit_process.php?id=$id\">$opponent</A><BR>";
}
mysql_close($db);
?>
edit_process.php:
<?php
include "config.php";
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");
$query = "SELECT opponent, league, score, result FROM matches WHERE id = $_GET[id]";
$result = mysql_query($query);
while($r=mysql_fetch_array($result))
{
$opponent=$r["opponent"];
$league=$r["league"];
$score=$r["score"];
$result=$r["result"];
echo "<form name=\"edit_process.php\" method=\"post\" action=\"edit_save.php?id=$_GET[id]\">
<p>Opponent :
<input type=\"text\" name=\"opponent\" value=\"$opponent\">
</p>
<p>League :
<input type=\"text\" name=\"league\" value=\"$league\">
</p>
<p>Score :
<input type=\"text\" name=\"score\" value=\"$score\">
</p>
<p>Result :
<input type=\"text\" name=\"result\" value=\"$result\">
</p>
<p>
<input type=\"submit\" name=\"Submit\" value=\"Save\">
</p>
</form>";
}
mysql_close($db);
?>