Cannot Display Array from Select Statement + Login question


Posted on 16th Feb 2014 07:03 pm by admin

Hi,
I'm new to PHP but so far so goog. I was assigend a project and I'm very close to completion.

I have a site that logs you in, sets a cookie, and then what I would like to do is depending on the user loging in, certain records from a table are selected and displayed

I have the following code:

Code: // Connects to your Database
mysql_connect("localhost", "root", "escrma") or die(mysql_error());
mysql_select_db("rma_portal") or die(mysql_error());

//Set Login Variable with the UserID
$login = $_COOKIE['ID_my_site'];

echo "This is it set to $login

";

// Collects data from "users" table
$data = mysql_query("SELECT *
FROM users, cust_info
WHERE cust_info.Cust_ID = '.$login'")
or die(mysql_error());

// puts the "users" info into the $info array
$info = mysql_fetch_assoc($data);

//Test Print of Login ID passed value
echo $data; WORKS Resource id #3
echo $info["Cust_Name"]; DOES NOT WORK
echo "$Cust_Name"; DOES NOT WORK

echo "$login

"; WORKS
echo $info["Cust_Company"]; DOES NOT WORK


1 Question is why I can echo the $login but then I canot pull anything from the query?
Table users
Cust_ID, Username, Password
Table cust_info
Cust_ID, Cust_Name, Cust_Company, Cust_Phone.....

2 I don't know if using the Cookie variable to use the login is a good idea. What would be the best way to pass the username to next page so I can use it in the SELECT ststement. Should I use a _SESSION global?

Thanks in advance

No comments posted yet

Your Answer:

Login to answer
263 Like 20 Dislike
Previous forums Next forums
Other forums

problem getting my contact form working
Yeah I know this is a pretty basic problem, but it's been a while since I've worked with PHP and I'm

Displaying image from database
Hi,

I've got a site where that's got a database behind it. Currently it has loads of items in

Will this protect from mysql injection?
I do not want anything like DROP TABLE to work or any type of coding..

Heres my code.. is it

Save username into DB
OkaY so I got my blog to actually save the posts and whatever, all I need now is for it to keep the

Module pool selction screen parameters combination logic
Hi floks,
Am new to the module pool development ,Recently i have created one program based on

Dynamic Data + Sql Server 2005 Enterprise?
Hi! I have just started to learn ASP.NET, and it looks like it is quite a lot to learn. Im not reall

What exactly is net neatrality?
What exactly is it? I think it's anti-censorship and... stuff... but I don't really understand it

Odd or Even
Inside of a while loop I need to echo several rows of info...easy enough.

In the loop (for th

CURL question
i am wondering if it's possible to use multi curl with login something like

login once to web

New to Arrays
Hi I am new to PHP (a week and a half now) and I am just beginning to read about arrays. I understan

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash