พบกับบทความเกี่ยวกับคอมพิวเตอร์และ programming ได้ที่ http://articles.modoeye.com | บล็อกอาหาร
PHP development / แนะนำเรื่อง error ด้วยครับ
Anan
Anan
Tue 10 Oct 2006 21:36:38

สวัสดีครับ

 

ขอคำแนะนำและรบกวนด้วยครับ   ผม copy code insert ข้อมูล เข้า Mysql ที่ผมเขียนเอง และใช้งานได้ แล้วมาเปลี่ยนแค่ชื่อ database จากชื่อ company มาเป็น test เพราะต่างฐานข้อมูลกัน ปรากฎว่าเกิด error ดังนี้ครับ

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\appserv\www\test\login\login_regist.php on line 27

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in c:\appserv\www\test\login\login_regist.php on line 28
Error adding to table.

 

พยายามหาแต่ก็หาไม่เจอครับ โดย code ที่ผมเขียนได้แก่

 

<?

error_reporting(E_ALL ^ E_NOTICE);

session_start();

 

$dbhost="localhost";

$dbname="test";

$dbuser="root";

$dbpass="";

 

if(trim($_POST['code']) !=($_SESSION['ses_code']))

{

   echo"<b>Code does not correct. </b>";

   echo"<a href=add_index.php><b>Please add your company again !</b>";

   exit;

}

 

$link=mysql_connect("localhost","root","");

if (!$link)

{

                print("Error");

}

else

{

                mysql_select_db("test",$link);

                $sql="select email1 from company where email1='$email1'";

                $res=mysql_query($sql, $link);

                $n=mysql_num_rows($res);

                mysql_free_result($res);

                if($n==0)

                {

                $sql="INSERT into test(username, password,company, country, email1, productd, agri, alkohol, nonal, bakery, mail, fee, dtnow)

               

                values('$email1', '$email1', '$country', '$email1', '$productd', '$agri', '$alkohol', '$nonal', '$bakery', '$mail', '$fee', CURRENT_TIMESTAMP)";

 

                $res=mysql_query($sql, $link);

                if($res==1)

                                print("Adding to database is OK.");

                else

                                print("Error adding to table.");

                }

                else

                {

                                print("This email already exists.");

                }

 

}

mysql_close();

 

?>

 

รบกวนด้วยครับ

 

อนันต์

Administrator
Wed 11 Oct 2006 02:28:32
ลองทำการ echo คำสั่ง $sql ดูครับ แล้วเอาไป run ใน phpMyAdmin ดูครับ
Reply
Name:
E-mail:
Home | Services | Forum | Classified | Directories | Support | Contact
ATOM feed RSS 0.9 feed RSS 1.0 feed RSS 2.0 feed
Copyright © 2005 - 2007 Modoeye.com, All Rights Reserved.
Disclaimer | Privacy policy | Term of Use | Term of Services
Valid XHTML Valid CSS! PHP: Hypertext Preprocessor MySQL database Apache Powered! FreeBSD Power to serve
Modoeye Sitemap Client login