icez Posted December 31, 2008 Share Posted December 31, 2008 Hey, On my page, I have this error : Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'match ORDER BY id' at line 1 And I have no clue why I have this error... My code : <?php } if($page == match){ echo "<br /><br />"; $query = "SELECT id, match, date FROM match ORDER BY id"; $result = mysql_query($query) or die('Error : ' . mysql_error()); ?> <table width="600" border="0" cellpadding="5" cellspacing="1" bgcolor="#BBD9EE"> <tr align="center" bgcolor="#BBD9EE"> <td width="500"><strong>Clan - Date</strong></td> <td width="150"><strong>Action</strong></td> </tr> <?php while(list($id, $match, $date) = mysql_fetch_array($result, MYSQL_NUM)) { ?> <tr bgcolor="#FFFFFF"> <td width="500"> <?php echo $match;?> - <?php echo $date;?> </td> <td width="150" align="center"> <a href="javascript:delMatch('<?php echo $id;?>','<?php echo $match;?>');">delete</a> </td> </tr> <?php } ?> </table> <?php if(isset($_POST['save77'])) { $match = $_POST['match']; $date = $_POST['date']; $query = " INSERT INTO match (match, date) ". " VALUES ('$match', '$date')"; mysql_query($query) or die('Error ,query failed'); echo '<b><font color=\"red\">Future Match Ajouter.</b></font><br /><a href="admin.php?page=match">Retour</a><br /><br />'; } ?> <form method="post"> <table width="700" border="0" cellpadding="2" cellspacing="1"> <tr> <td width="100"><b>Match :</b></td> <td><input name="match" type="text"></td> </tr> <tr> <td width="100"><b>Date :</b></td> <td><input name="date" type="text"></td> </tr> <tr> <td colspan="2" align="center"><input name="save77" type="submit" value="Envoyer"></td> </tr> </table> </form> And Mysql table : CREATE TABLE `match` ( `id` int(11) NOT NULL auto_increment, `match` varchar(50) NOT NULL, `date` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) Quote Link to comment https://forums.phpfreaks.com/topic/138945-solved-i-dont-understand-why-i-have-this-error/ Share on other sites More sharing options...
xtopolis Posted December 31, 2008 Share Posted December 31, 2008 MATCH is a reserved word. change the column name, or `backtick` it out $query = "SELECT id, `match`, date FROM match ORDER BY id"; Quote Link to comment https://forums.phpfreaks.com/topic/138945-solved-i-dont-understand-why-i-have-this-error/#findComment-726746 Share on other sites More sharing options...
icez Posted December 31, 2008 Author Share Posted December 31, 2008 Thank you, but I need to add quotes to both. $query = "SELECT id, `match`, date FROM `match` ORDER BY id"; Quote Link to comment https://forums.phpfreaks.com/topic/138945-solved-i-dont-understand-why-i-have-this-error/#findComment-727156 Share on other sites More sharing options...
xtopolis Posted December 31, 2008 Share Posted December 31, 2008 Yes. But a ' is not the same as a ` . Better to rename your column, imo. Quote Link to comment https://forums.phpfreaks.com/topic/138945-solved-i-dont-understand-why-i-have-this-error/#findComment-727244 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.