21,886
社区成员
发帖
与我相关
我的任务
分享
<?php
try {
$dns = 'mysql:host=localhost;dbname=satcliv8;port=3306';
$utilisateur = 'root';
$motDePasse = '';
$connection = new PDO( $dns, $utilisateur, $motDePasse ,
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
} catch ( Exception $e ) {
echo "Connection à MySQL impossible : ", $e->getMessage();
die();
}
?>
public function insertR(){
global $connection;
$sql=$connection->prepare("insert into reponse SET MSISDN=:ref_clt,Q1=:r1,Q2=:r2,Q3=:r3,Q4=:r4,Q5=:r5,Q6=:r6,Q6b=:r6c,Q7=:r7,Q8=:r8,Date_Reponse=:date,Type_Commande=:type,Host_Reponse=:host,Ip_Reponse=:ip,semaine_reponse=:sem") or die (mysql_error());
$sql->bindValue('ref_clt',$this->MSISDN);
$sql->bindValue('r1',$this->Q1);
$sql->bindValue('r2',$this->Q2);
$sql->bindValue('r3',$this->Q3);
$sql->bindValue('r4',$this->Q4);
$sql->bindValue('r5',$this->Q5);
$sql->bindValue('r6',$this->Q6);
$sql->bindValue('r6c',$this->Q6b);
$sql->bindValue('r7',$this->Q7);
$sql->bindValue('r8',$this->Q8);
$sql->bindValue('date',$this->date);
$sql->bindValue('type',$this->type);
$sql->bindValue('host',$this->hostname);
$sql->bindValue('ip',$this->ip);
$sql->bindValue('sem',$this->sem);
$sql->execute();
//var_dump($sql);
}
但是代码应该是没有问题的, 是上一个人写好并且测试过成功的,然后我拷贝到我的电脑里并且用phpmyadmin新建了一个一样数据库, 但我的就没有办法存入