导入数据库出现错误 求大神帮助
导入数据库mysql出现这样的错误请问怎么解决下面是PHP是这样的请问哪里错了<?php$conn=mysql_connect("localhost","root","r...
导入数据库mysql
出现这样的错误请问怎么解决
下面是PHP 是这样的 请问哪里错了
<?php
$conn = mysql_connect("localhost", "root", "root") or die( mysql_error());
mysql_select_db('sgk',$conn)or die(mysql_error());
mysql_query("set names 'utf8'");
$file=file('tt.txt');
$d=$c=count($file);
$a=1000;
//$sql2="INSERT INTO weibo (id,username,password)VALUES";
$sql2="INSERT INTO `weibo` (id,username,password)VALUES";
foreach ($file as $k=>$value){
$data=preg_split("/[\s,]+/",$value);//正则匹配空格逗号可以根据自己的需要调整
//$data=preg_split(",",$value);
$username=trim(addslashes($data[0]));
$password=trim(addslashes($data[1]));
$sql="('$username','$password')";
$sql=$sql2.$sql.';';
if(mysql_query($sql)){
$dd=$d-=1000;
echo $dd."\n";
//echo $dd."/\n/";
}else{echo $sql;}
unset($sql);
$a+=1000;
}
?> 展开
出现这样的错误请问怎么解决
下面是PHP 是这样的 请问哪里错了
<?php
$conn = mysql_connect("localhost", "root", "root") or die( mysql_error());
mysql_select_db('sgk',$conn)or die(mysql_error());
mysql_query("set names 'utf8'");
$file=file('tt.txt');
$d=$c=count($file);
$a=1000;
//$sql2="INSERT INTO weibo (id,username,password)VALUES";
$sql2="INSERT INTO `weibo` (id,username,password)VALUES";
foreach ($file as $k=>$value){
$data=preg_split("/[\s,]+/",$value);//正则匹配空格逗号可以根据自己的需要调整
//$data=preg_split(",",$value);
$username=trim(addslashes($data[0]));
$password=trim(addslashes($data[1]));
$sql="('$username','$password')";
$sql=$sql2.$sql.';';
if(mysql_query($sql)){
$dd=$d-=1000;
echo $dd."\n";
//echo $dd."/\n/";
}else{echo $sql;}
unset($sql);
$a+=1000;
}
?> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询