Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-09-2003, 10:26 AM
progmania's Avatar
Inspired Webmaster
 
Join Date: Aug 2003
Location: localhost PJ
Posts: 101
Rep Power: 64
progmania is on a distinguished road
Send a message via Yahoo to progmania
mysql+php : help find the error

saya ada buat satu db. tapi bila saya buat coding kat bawah nih... keluar error... mula2 saya buat camni takde masalah:
$result = mysql_query("SELECT * from personal WHERE emp_id=$pwd");
Tapi bila tambah cam kat bwh nih keluar error..

<?php

$result = mysql_query("SELECT * from personal WHERE emp_id=$pwd AND emp_name=$name");

while ($row = mysql_fetch_object($result)) {
?><p>

Name : <?php echo $row->emp_name; ?><br>
IC : <?php echo $row->emp_ic; ?><br>
Gender : <?php echo $row->emp_gender; ?><br>
Status : <?php echo $row->emp_status; ?><br>
Address : <?php echo $row->emp_address; ?><br>
Phone : <?php echo $row->emp_phone; ?><br>
Last Login Date: <?php echo $row->emp_logdate; ?><br>
<?php
}
mysql_free_result($result);


?>



Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in c:\web\sys\empsys\personal_info.php on line 5

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in c:\web\sys\empsys\personal_info.php on line 17
__________________
Set the goal, push to the limit, reach the top and u'll be proud.. Try lah!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-09-2003, 11:13 AM
zaimlah's Avatar
Inspired Webmaster
 
Join Date: Jul 2001
Location: ttdi
Posts: 129
Rep Power: 89
zaimlah is on a distinguished road
progmania:

cuba check the sql query "SELECT * from personal WHERE emp_id=$pwd" ... ada tak salah eja table name atau column name...

yg keduanya, tambahkan 'single quotes' pada $pwd dan $name, macam ni:
PHP Code:
$result mysql_query("SELECT * from personal WHERE emp_id='$pwd' AND emp_name='$name'"); 
__________________
blog:zaim_bakar_blog | biz:box
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-09-2003, 11:20 AM
progmania's Avatar
Inspired Webmaster
 
Join Date: Aug 2003
Location: localhost PJ
Posts: 101
Rep Power: 64
progmania is on a distinguished road
Send a message via Yahoo to progmania
semua nama,table,colum,var dlm tu betul... dah cuba dah tambah tanda ' error tak keluar tapi data dlm database pun tak keluar gak... kosong je....
__________________
Set the goal, push to the limit, reach the top and u'll be proud.. Try lah!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-09-2003, 12:07 PM
progmania's Avatar
Inspired Webmaster
 
Join Date: Aug 2003
Location: localhost PJ
Posts: 101
Rep Power: 64
progmania is on a distinguished road
Send a message via Yahoo to progmania
ok problem solve (change whole coding).... tapi nak tanya boleh tak kalau nak buat cam coding kat atas tu

$result = mysql_query("SELECT * from personal WHERE emp_id=$pwd AND emp_name=$name");

tapi panggil sekali 2 table. contoh table personal dan company, pastu display sekali....

TQ...
__________________
Set the goal, push to the limit, reach the top and u'll be proud.. Try lah!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-09-2003, 12:32 PM
zaimlah's Avatar
Inspired Webmaster
 
Join Date: Jul 2001
Location: ttdi
Posts: 129
Rep Power: 89
zaimlah is on a distinguished road
Quote:
Originally posted by progmania
...boleh tak kalau nak buat cam coding kat atas tu

$result = mysql_query("SELECT * from personal WHERE emp_id=$pwd AND emp_name=$name");

tapi panggil sekali 2 table. contoh table personal dan company, pastu display sekali....
boleh, gunakan dot notation, macam ini:
Code:
SELECT * FROM personal, company WHERE personal.emp_id=$pwd AND personal.emp_name=$name
AND company.whatever=$ntahapapa OR company.apapa=$whatever
cara ni selalunya digunakan kalau dua-dua table ada link (menggunakan primary/foreign key), contohnya:
Code:
SELECT * FROM personal, company WHERE personal.emp_id=company.emp_id
sorrylah kalau tak paham sebab aku pun bukannya expert dalam SQL...

link utk belajar SQL: http://www.w3schools.com/sql/default.asp
__________________
blog:zaim_bakar_blog | biz:box
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 03-09-2003, 12:42 PM
progmania's Avatar
Inspired Webmaster
 
Join Date: Aug 2003
Location: localhost PJ
Posts: 101
Rep Power: 64
progmania is on a distinguished road
Send a message via Yahoo to progmania
ok thank you.... dah jadi memang saya ader pakai primary key pun....walaupun ader skit error tapi rasernyer boleh di modify sendiri... thanks Zaimlah...
__________________
Set the goal, push to the limit, reach the top and u'll be proud.. Try lah!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
where can i find these type of scripts! mr_kim85 Website Programming 2 21-08-2006 06:42 AM
Funny cant find davcheong Showcase 4 02-11-2005 12:33 AM
Internal Server Error - ASP error ladyheart2612 Website Programming 0 21-07-2005 09:22 AM
How did you find your host? Helen Paid Hosting Discussion Forum 10 29-10-2004 06:55 PM
vBulletin Style *Where 2 Find* zmiey Website Programming 9 09-10-2002 05:14 PM



All times are GMT +8. The time now is 01:40 AM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59