I’m trying to write an online form for a local football (soccer) team which goes through the starting line-up and puts all the data saved row-by-row into a mysql database. However, my data is not being saved in the database and I can’t work out why - anyone help please:
Yep, I tried adding or die(mysql_error()); but I get no error message back when I hit submit which is very annoying!
I don’t get why I am missing two fields though:
position,shirt_number,player_id,goals,cards,substituted,used_sub,injury
// All held in $row which I explode on
season,report_id
//Grabbed from my $_GET values in the script
//$report_id = $_GET['report_id'];
//$currentSeason = $_GET['currentSeason'];
It’s almost like i’m hitting submit and my form is ignoring the foreach where it inserts the data in the database as I don’t even get a MYSQL error as mentioned earlier when I add or die(mysql_error) ?
if you add 'or die(mysql_error()) to the end of the query line it would probably say something like ‘field count worng’;
$result = mysql_query("Insert into player_stats (position,shirt_number,player_id,goals,cards,substituted,used_sub,injury,season,report_id)
values('$position','$row','$currentSeason','$report_id')") or die(mysql_error());
}
Thanks for your help. I get the $_GET values from the URL string, so for example it could read:
file.php?report_id=12¤tSeason=1011
However I don’t think it’s anything to do with the query, I just think that for some reason my form never processes the query for example within my code i’ve asked it to print “I AM A MONKEY” when I hit submit and it never prints it.
I can even change the table name and when I hit submit I get no errors, so for some reason which I can’t see my foreach loop is being ignored it seems
<?
if(isset($_REQUEST['Submit']))
{
$report_id = $_GET['report_id'];
$currentSeason = $_GET['currentSeason'];
foreach($_REQUEST['r'] as $position => $row)
{
$row = implode("', '",$row);
$result = mysql_query("Insert into a_table_that_does_not_exist(position,shirt_number,player_id,goals,cards,substituted,used_sub,injury,season,report_id)
values('$position','$row','$currentSeason','$report_id')");
echo "I am a Monkey";
}
header("Location: ../menu.php");
} //End of POST submit
?>
All to do with a scipt I put into my system with regards to mysql_real_escape_string. As soon as I saw the error message I knew exactly what it was, but not seeing the error was the problem. Thanks for your help :tup: