tags:

views:

84

answers:

2

PHP/MySQL newbie question.

I have a database I've imported into my local phpmyadmin. However it seems I can't access it from my a php application. The connection string seems right and when I try to authenticate user credentials to access database information, no problems.

However authenticate everyone and knows when I put in fake credentials. Still it won't pull any other information from the database.

For instance, once a users login they should see something like, "Hello username", that kind of thing. At this point I see "Hello" without the username. Any ideas what i might be missing?

A: 
queryne
let me know if this is readable. haven't posted code on OS before.
queryne
This is good, but you should edit and add it to your question, rather than post it here (this is the 'answer' section of the page)
Mark Snidovich
A: 

I noticed you are using the root user (though I'm not sure if this was added merely for posting purposes here.) Depending on what hosting environment you are using this may or may not be a problem - some shared hosts force you to assign a user for databases in MySQL.

From the looks of things your query should be executing and returning a number of rows at the least. Have your tried print_r on the results array? If so, can you post the output?

If you are successfully getting results from the database, I don't see anywhere in your posted code a conditional that echos out a success message. You may want to check isset() against the $_SESSION superglobal keys you assign ( recordID and firstName) and if true echo out a success message if you have not already done so.

Just a thought as well - I noticed you are using sprintf to format out your query - it may be a bit too robust for what you're trying to accomplish, but using PDO to get parameterized sql queries is a nice way to get that job done where available. Introduction to PHP 5 PDO

DeaconDesperado