$db=mysql_connect("localhost","root","mysql"); mysql_select_db("mb",$db); $sqltxt="select * from user where name=".$name; $Result=mysql_query($sqltxt,$db); $myrow=mysql_fetch_row($Result); if($myrow.next()){ if($myrow.getint(".$id.").equals(id)) { echo "success"; }
else echo "!=id";
} else
echo " $myrow.next() is wrong "; 这时怎么就进不了index.php呢, 地址是对的,http://localhost/exe/do_login01.php .next() is wrong 应该是这几句有问题 $sqltxt="select * from user where name=".$name; $Result=mysql_query($sqltxt,$db); $myrow=mysql_fetch_row($Result); if($myrow.next()){ if($myrow.getint(".$id.").equals(id)) 帮我看看怎么改??
地址是对的,http://localhost/exe/do_login01.php 输不了 success 输出 .next() is wrong 应该是这几句有问题 $sqltxt="select * from user where name=".$name; $Result=mysql_query($sqltxt,$db); $myrow=mysql_fetch_row($Result); if($myrow.next()){ if($myrow.getint(".$id.").equals(id)) 帮我看看怎么改?? 谢谢
还没用过.next()那,呵呵~~..怎么感觉有点像用JSP的意思 $sqltxt="select * from user where name=".$name; //name= name like? $Result=mysql_query($sqltxt,$db); $myrow=mysql_fetch_row($Result); print_r($myrow);exit;先看看是什么东西,就能找到你要的东西了!
for($r=0;$r<count($myrow);$r++){ echo $row[$r]; } $sqltxt="select * from user where name=".$name; 改为: $sqltxt="select * from user where name = "'.$name.'" "; 再试试看!!
where (字段)+ 判断符 + 值
楼主还是多看下基础知识吧
上面 echo $row[$r]; 手打,失误 改为 echo $myrow[$r];
$sqltxt="select * from user where name = '".$name."' "; .为连接字符串的符号, '".$name."' 单引在外,双引在内。
<?php
$db=mysql_connect("localhost","root","mysql");
mysql_select_db("mb",$db);
$sqltxt="select* from user";
$Result=mysql_query($sqltxt,$db);
while($myrow=mysql_fetch_row($Result))
{
echo $myrow[1];
}
?>这样就可连上数据库,
并输出 表内容 smb
(2)
do_login01.php
$id=intval($_POST[id]);
$name=$_POST[name];
$db=mysql_connect("localhost","root","mysql");
mysql_select_db("mb",$db);
$sqltxt="select * from user where name=".$name;
$Result=mysql_query($sqltxt,$db);
$myrow=mysql_fetch_row($Result);
if($myrow.next()){
if($myrow.getint(".$id.").equals(id))
{
echo "success";
}
else
echo "!=id";
} else
echo " $myrow.next() is wrong ";
这时怎么就进不了index.php呢,
地址是对的,http://localhost/exe/do_login01.php
.next() is wrong
应该是这几句有问题
$sqltxt="select * from user where name=".$name;
$Result=mysql_query($sqltxt,$db);
$myrow=mysql_fetch_row($Result);
if($myrow.next()){
if($myrow.getint(".$id.").equals(id))
帮我看看怎么改??
输不了 success
输出 .next() is wrong
应该是这几句有问题
$sqltxt="select * from user where name=".$name;
$Result=mysql_query($sqltxt,$db);
$myrow=mysql_fetch_row($Result);
if($myrow.next()){
if($myrow.getint(".$id.").equals(id))
帮我看看怎么改??
谢谢
$Result=mysql_query($sqltxt,$db);
$myrow=mysql_fetch_row($Result);
print_r($myrow);exit;先看看是什么东西,就能找到你要的东西了!
if
又应该怎么写呢,
if($myrow.next()){
if($myrow.getint(".$id.").equals(id)) lz java转过来的吧,,php里面调用类的方法用->$myrow=mysql_fetch_row($Result);
if($myrow.next()){
if($myrow.getint(".$id.").equals(id))
改为:while ($myrow=mysql_fetch_row($result)){
for($r=0;$r<count($myrow);$r++){
echo $row[$r];
}
$sqltxt="select * from user where name=".$name;
改为:
$sqltxt="select * from user where name = "'.$name.'" "; 再试试看!!
楼主还是多看下基础知识吧
改为 echo $myrow[$r];
.为连接字符串的符号, '".$name."' 单引在外,双引在内。
没事的话,看看别人的登录代码
15楼的只是显示,没有判断ID呀,怎么根据name去判断ID是否等于表中的ID呢,
就是下面的
$myrow=mysql_fetch_row($Result);
if($myrow.next()){
if($myrow.getint('".$id."').equals(id))
怎么修改。。
谢谢
$id=intval($_POST[id]);
$name=$_POST[name];
$db=mysql_connect("localhost","root","mysql");
mysql_select_db("mb",$db);
$sqltxt="select* from user where name='".$name."'";
$Result=mysql_query($sqltxt,$db);
$row = mysql_fetch_array($Result);
$iddb =$row[0];
$namedb =$row[1];
if($iddb == $id)
{
echo ("登陆成功");
}
else
{
echo ("登陆失败");
}
谢谢大家,