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

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-09-2006, 01:36 AM
Novice Webmaster
 
Join Date: Sep 2006
Location: penang
Posts: 20
Rep Power: 0
slier is on a distinguished road
guide me pleaseee

hello...tolong aku sikit.....aku dah kasji kod ni dah dekat 4 jam dah ni...aku x tau dah nak buat apa ngan eror yang aku dapat ni....

macam ni....aku try nak buat authentication page....
index.php----page utk lgin
proses.php---script nak proses username/pass from index.php
member.php----klu login succes nak redirect ker page ni...

ni coding utk index.php:
PHP Code:
<?php
echo"
<form  action=\"proses.php\" method=\"post\">
<table border=\"1\">
<tr>
<td><b>Nama</b></td>
<td><b>Pass</b></td>
</tr>
<tr>
<td><input type=\"text\" name=\"nama\"></td>
<td><input type=\"password\" name=\"pass\"></td>
</tr>
<tr>
<td colspan=\"10\"><input type=\"submit\" name=\"submit\" value=\"Hantar\">&nbsp;&nbsp;<input type=\"reset\" value=\"Reset\"></td>
</table>
</form>"
;
?>
ni coding utk proses.php:
PHP Code:
<?php
$host
="localhost";
$user="root";
$pass="";
$db="projek4";
if(!isset(
$_POST['submit']))
{
die(
"Form Must Be Submit");
}
$conn=mysql_connect($host,$user,$pass)
or die(
mysql_error());
mysql_select_db($db,$conn)
or die(
mysql_error());
$query=mysql_query("select * from user where usern='".$_POST['nama']."' and pass='".$_POST['pass']."',$conn")
or die(
mysql_error());
$num=mysql_num_rows($query);
if (
$num 0)
{
$rowmysql_fetch_row($query);
session_start();
$_SESSION['user']=$row['usern'];
echo 
"<meta http-equiv='refresh' content='0;URL=members.php'>";
}
echo
"Invalid Username....Password";

?>
masaalahnya bila aku enter username dan password dekat index.php then tekan enter...aku dapat error ni:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #2' at line 1...

so kengkawan tolong aku yer.....

Last edited by mysticmind; 13-09-2006 at 02:09 PM. Reason: change php code to colored view.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 12-09-2006, 02:44 PM
Novice Webmaster
 
Join Date: Sep 2006
Location: penang
Posts: 20
Rep Power: 0
slier is on a distinguished road
ermmm...takda sesapa nak tolong aku ker...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-09-2006, 03:26 PM
limcs's Avatar
Administrator
 
Join Date: Jul 2006
Location: Penang
Posts: 1,768
Rep Power: 10
limcs has a spectacular aura about limcs has a spectacular aura about limcs has a spectacular aura about
Quote:
Originally Posted by slier
ermmm...takda sesapa nak tolong aku ker...
I would love to, but can't really help you debug it. Perhaps you can double check your database username, password, and name?
__________________
Read the Rules
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 13-09-2006, 01:55 PM
New kid on the block
 
Join Date: Aug 2006
Location: Perak
Posts: 7
Rep Power: 0
chan0923 is on a distinguished road
I think the problem is with your query.

The word "user" is actually a reserved word in MySQL. You can either use :

Code:
Select * from `user` ...
(user ` to let MySQL know that this is a table name, not a keyword)

Or rename your table to other name except "user"


My advice is, try not to use keyword as table or column name. Name a table with a prefix like AppName_user (example, if your system is call ABC, then user ABC_user, ABC_doc, ABC_tablename ...). This practise makes your database easier to manage because you know which table belongs to which system.

Hope this solve your problem
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 13-09-2006, 02:05 PM
mysticmind's Avatar
Super Moderator
 
Join Date: Jun 2001
Location: Mystic Kingdoms
Posts: 2,687
Rep Power: 145
mysticmind will become famous soon enough mysticmind will become famous soon enough
Send a message via Yahoo to mysticmind
ermm..
cube buang perenggan nih dulu ..
PHP Code:
echo "<meta http-equiv='refresh' content='0;URL=members.php'>"
ganti dengan echo " berjaya";

sebenarnya aku akt opis pakai mac. tak dapat nak kaji coding ko ..
tapi seingat aku dulu.. aku buat redirect camtuh ada error..

better pakai Php location kot..

sebab dalam tag meta refresh tuh ada banyak quote --> ' ? "

mungkin jer la.. dah cuba check line resource#2 line 1 tuh rujuk kod line mana..
__________________
Personal's Blog! - Malaysian Artist!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 13-09-2006, 10:03 PM
Novice Webmaster
 
Join Date: Sep 2006
Location: penang
Posts: 20
Rep Power: 0
slier is on a distinguished road
thnks guys....aku dah solve sendrik kod aku tu...
aku tukar dari yg ni:

$query=mysql_query("select * from user where usern='".$_POST['nama']."' and pass='".$_POST['pass']."',$conn")

kepada ni:

$query=mysql_query("select * from user where usern='".$_POST['nama']."' and pass='".$_POST['pass']."'")

problem solved....
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
Myinfo guide razim172 Websites Review and Suggestion 0 17-10-2006 12:50 PM
My Info Guide razim172 Websites Review and Suggestion 0 08-09-2006 10:29 AM
paysat integration guide tomy_orange E-Commerce 0 13-09-2005 12:21 AM
Web Style Guide lcf Websites Review and Suggestion 5 24-05-2004 06:07 PM
My Palm Guide ibnu_ariff Websites Review and Suggestion 4 03-10-2003 12:27 AM


All times are GMT +8. The time now is 12:07 PM. 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 60 61