sebbyw

Registered
Feb 14, 2014
1
0
1
cPanel Access Level
Website Owner
Hello everyone. I just want to say I am very new to cpanel forums. I know html, a bit of php and css. Now I took some code from here to make a php form: /http://www.phpeasystep.com/phptu/6.html I took all of the code from there and made some tweaks to try and fix this error. When I uploaded it to my cpanel file manager I tested to see if it works and got this error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/sebbyw/public_html/checklogin.php on line 27
Wrong Username or Password

Here is the code in my checklogin.php:

Code:
<?php

ob_start();
$host="localhost"; // Host name 
$username="sebbyw_root"; // Mysql username 
$password="password123"; // Mysql password 
$db_name="sebbyw_test"; // Database name 
$tbl_name="sebbyw_members"; // Table name 

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// Define $myusername and $mypassword 
$myusername=$_POST['myusername']; 
$mypassword=$_POST['mypassword']; 

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result = mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows ($result);

// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){

// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword"); 
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
?>
Can someone please help me to fix it. Thank you very much. Also, I have not made a "Registration" page yet.
If you need more info to help find the bug please just ask. The site: - Removed -
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
Hello :)

You will likely receive more assistance with developing a PHP script at forum that specializes in PHP or web design. These forums are primarily intended for issues related to the cPanel software itself. You may want to try making sure the database user is added to the database, or re-create the MySQL username with the password you have entered in your script configuration to make sure there were no typing mistakes.

Thank you.