Not working

The below PHP code is not working, i downloaded it from online i have changed the mysql connection to match my database but still it wouln’t connect to below is the code and the javescript to submit the form , help help cant see what am doing wrong

CONFIG.PHP<?php mysql_connect("localhost","root"); mysql_select_db("shop"); ?>

ADMIN INDEX[code]<?php
error_reporting(1);
include(“config.php”);
$name=$_REQUEST[‘t1’];
$pass=$_REQUEST[‘p1’];

if($_REQUEST[‘sub’])
{
$sel=mysql_query(“select name,pass from details where name=’$name’”);
$arr=mysql_fetch_array($sel);
if($arr[‘name’]==$name and $arr[‘pass’]==$pass)
{
session_start();
$_SESSION[‘eid’]=$name;
header(“location:home.php”);
}
else
{
$er=“name and password do not match”;
}
}
?>

[/code]

Well, first, please make your subject something that pertains to your problem. Every post here is not working!
LOL It helps as some programmers here know a lot about some things more than others and you get more
responses that way.

Now, first MySQL is no longer used on a lot of servers. It has be predicated. The two options now are
either PDO or MySQLi (which stands for improved.) If your pages are hosted on your computer using
WAMP or XAMP, you should be able to use the localhost and root. But, if it is hosted online somewhere,
you may have to use a connection string that is set up by the hosting company. If so, you can look at your
control panel and there will be a sample for you there.

Here is a link for w3Schools which is a good tutorial on how to set up your connection… It might help you
a bit with the minor changes that are in the improved version of MySQLi.
http://www.w3schools.com/php/php_mysql_connect.asp

Lastly, you do not have any error checking in your database connection nor in your queries. You need to
add those as it will show what your problem is. For instance, you connect to the database and select the
“shop” database. But, you do not know if either the connection or db-selection failed. It would NOT give
you any error messages unless you check for htem and display them. It does not show these errors by
default. In the link I gave you, it shows how you need to check for the connection to see if it fails. If it
does fail, you can display the error and find out why. ( mysqli_connect_error() ) The code in the link
has that in place!

Hope that helps you sort it out. Good luck!

Thanks verry much for your reply and i’ll do as said

Sponsor our Newsletter | Privacy Policy | Terms of Service