Pourquoi cet échec? Je suis connecté à la bonne DB, et les clés sont définitivement là.mysqli prepare statement en utilisant select failing pour une raison inconnue
//verify key against key list in database
if ($prep_statement = $db->prepare("SELECT id FROM key_list WHERE keys=?"))
{
$prep_statement->bind_param('s',$key);
$prep_statement->execute();
echo $prep_statement->num_rows;
$prep_statement->close();
} else {
printf("Prepared Statement Error: %s\n", $db->error);
die();
}
je reçois l'erreur suivante et l'instruction if est soit faux
Prepared Statement 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 'key=?' at line 1
Voilà ma structure de table:
-- MySQL dump 10.11
--
-- Host: localhost Database: gameserverdev
-- ------------------------------------------------------
-- Server version 5.0.51a-24+lenny4
/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;
/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;
/*!40101 SET @[email protected]@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @[email protected]@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @[email protected]@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @[email protected]@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `key_list`
--
DROP TABLE IF EXISTS `key_list`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `key_list` (
`id` bigint(20) unsigned NOT NULL auto_increment,
`keys` char(16) NOT NULL,
`datetime_registered` datetime NOT NULL,
`banned` tinyint(1) NOT NULL,
`comment` char(255) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
--
-- Dumping data for table `key_list`
--
LOCK TABLES `key_list` WRITE;
/*!40000 ALTER TABLE `key_list` DISABLE KEYS */;
INSERT INTO `key_list` VALUES (2,'1111222233334444','2010-07-31 16:04:30',0,NULL);
/*!40000 ALTER TABLE `key_list` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping routines for database 'gameserverdev'
--
DELIMITER ;;
DELIMITER ;
/*!40103 SET [email protected]_TIME_ZONE */;
/*!40101 SET [email protected]_SQL_MODE */;
/*!40014 SET [email protected]_FOREIGN_KEY_CHECKS */;
/*!40014 SET [email protected]_UNIQUE_CHECKS */;
/*!40101 SET [email protected]_CHARACTER_SET_CLIENT */;
/*!40101 SET [email protected]_CHARACTER_SET_RESULTS */;
/*!40101 SET [email protected]_COLLATION_CONNECTION */;
/*!40111 SET [email protected]_SQL_NOTES */;
-- Dump completed on 2010-07-31 23:00:56
J'ai corrigé mon code. Même erreur Mise à jour du message original – Eric
A-ha, je n'ai pas remarqué avant, mais vous utilisez un mot réservé. Réponse mise à jour – Charles
Fonctionne maintenant. J'ai essayé les clés et les clés, mais apparemment, elles sont toutes les deux réservées. Merci!! – Eric