# Not working 

**URL:** <https://www.phphelp.com/t/not-working/24745>\
**Category:** MySQL database\
**Created:** [November 24, 2015, 5:47pm UTC](https://www.phphelp.com/t/not-working/24745 "2015-11-24T17:47:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KELVINEJIMOGU](https://www.phphelp.com/letter_avatar_proxy/v4/letter/k/35a633/32.png) [@KELVINEJIMOGU](https://www.phphelp.com/u/KELVINEJIMOGU)\
**Post date:** [November 24, 2015, 5:47pm UTC](https://www.phphelp.com/t/not-working/24745/1 "2015-11-24T17:47:45Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![ErnieAlex](https://www.phphelp.com/letter_avatar_proxy/v4/letter/e/bc8723/32.png) [@ErnieAlex](https://www.phphelp.com/u/ErnieAlex)\
**Post date:** [November 24, 2015, 6:34pm UTC](https://www.phphelp.com/t/not-working/24745/2 "2015-11-24T18:34:39Z")

</div>

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](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!

---

<div class="post-metadata">

**Author:** ![KELVINEJIMOGU](https://www.phphelp.com/letter_avatar_proxy/v4/letter/k/35a633/32.png) [@KELVINEJIMOGU](https://www.phphelp.com/u/KELVINEJIMOGU)\
**Post date:** [November 24, 2015, 7:20pm UTC](https://www.phphelp.com/t/not-working/24745/3 "2015-11-24T19:20:38Z")

</div>

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