Jump to content

Problem with database query


krappleby

Recommended Posts

Hi guys, hoping someone can help, i have a small piece of code to query a database table, basically for a login script, however for some reason its just not working.. i have been through this small piece of code numerous times and i just cannot see the problem.. does anyone have any insights..

 

$checklogin = "select * from logininfo where User = '" . $_POST['username'] . "' AND password2 = '" . $_POST['password'] . "'";
$row = mysql_query($checklogin) or die ("could not check details"); 

from what i can tell, code is fine but all i keep getting is Could not check details. connection is fine, it is completed on another file, which is included/ i just cant seem to see a problem.. 
 
cheers
keith
Link to comment
Share on other sites

A couple of things you should do to debug

 

echo $checklogin, to see if the query is as you expected

echo mysql_error() and let mysql tell you what's wrong.

 

 

Stop using mysql_* functions, they are obsolete. Best advice is switch to PDO.

 

Don't store passwords as plain text, use password_hash() and password_verify() functions.

 

Don't put user-provided data directly into the SQL statement. Use prepared queries.

Link to comment
Share on other sites

Hi,

 

Thanks for your reply, i did as you suggested and it turns out that it is my connection that is the problem.. i havent programmed php for about 10 years so i dont know the new systems but i cannot afford to get what i need done done, so i have been trying to do it myself. would you help me with teh connection and first query, with that help i can use your examples and will know how to do it. i have seen posts, but whatever i did using them didnt work. 

 

if you are willing to help. (i have an ability to understand when i see something working, there i s alot more ic an do myself when i see something working)

 

here is the connection i currently have

 

<?php
$servername = "localhost";
$username = "root";
$password = "******";
$dbname = "sales";
 
// Create connection
$conn = mysql_connect($servername, $username, $password, $dbname);
 
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
echo "Connected successfully";
?>
 
NOte this is for a private home network so will not be internet bound, 
 
i am using easyphp server, with mysql. database is set up and server is running
 
the actual query you have seen above.. 
 
if you are willing to help i can use your coding to work with the rest of the site. manipulating for what i need, i just dont have any idea how this new system works..
 
If you help i thank you for your assistance.
 
keith
Link to comment
Share on other sites

As was said - the MySQL* interface has been removed from the latest version of php. So - to help you make a connection using that set of functions would be a waste of everyone's time. Plus - your install may not even support it either. What version of PHP are you running? And - why not do a quick read on PDO and join the rest of us?

Link to comment
Share on other sites

http error 500..

 

 

you need to set up your development system so that php will help you and won't hide output and errors.

 

in the php.ini that php is using, set error_reporting = E_ALL, set display_errors = ON, and set output_buffing = OFF. restart your web server after making any changes to the php.ini.

 

to find the php,ini that php is using, create a .php script file with a phpinfo(); statement in it and browse to the url of the .php script. there is a line near the top named - Loaded Configuration File. this is the php.ini that php is using.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.