//其实我也就插入失败50次而已,没有一百次
//首先语句是mysqli_query,而不是mysql_query
//其次系统老是提示需要传入两个参数,是因为没把$con写进去
//看看http://www.runoob.com/php/func-mysqli-query.html的标准写法就知道了,我把两个参数写反了
if(mysqli_query($con,'insert into test1(username)values("abc")')){
echo "成功插入";
}else{echo "插入失败";
}
//首先语句是mysqli_query,而不是mysql_query
//其次系统老是提示需要传入两个参数,是因为没把$con写进去
//看看http://www.runoob.com/php/func-mysqli-query.html的标准写法就知道了,我把两个参数写反了
if(mysqli_query($con,'insert into test1(username)values("abc")')){
echo "成功插入";
}else{echo "插入失败";
}
2016-03-29
//这样写就没问题了
if(mysqli_select_db($con,'first')){
echo "选择数据库成功";
}else{
echo "选择数据库失败";
}
if(mysqli_select_db($con,'first')){
echo "选择数据库成功";
}else{
echo "选择数据库失败";
}
2016-03-29
我连接后 提示 Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in G:\wamp\www\index.php on line 2
2016-03-28
<?php //连接数据库
mysql_connect('127.0.0.1', 'code1', ''); mysql_select_db('code1'); mysql_query("set names 'utf8'"); //在这里进行数据查询
$res=mysql_query('select * from user');
$row=mysql_fetch_array($res);
var_dump($row);
mysql_connect('127.0.0.1', 'code1', ''); mysql_select_db('code1'); mysql_query("set names 'utf8'"); //在这里进行数据查询
$res=mysql_query('select * from user');
$row=mysql_fetch_array($res);
var_dump($row);
2016-03-25
经过测试,D:$q2=mysql_query(‘select count(*)from a’)
使用echo输出,显示
Catchable fatal error: Object of class mysqli_result could not be converted to string错误
使用print_r输出,显示
mysqli_result Object ( [current_field] => 0 [field_count] => 1 [lengths] => [num_rows] => 1 [type] => 0 )
明显了,这就是一组Object 对象
使用echo输出,显示
Catchable fatal error: Object of class mysqli_result could not be converted to string错误
使用print_r输出,显示
mysqli_result Object ( [current_field] => 0 [field_count] => 1 [lengths] => [num_rows] => 1 [type] => 0 )
明显了,这就是一组Object 对象