Solved

Simple MySql query headache

Posted on 2012-03-11
3
268 Views
Last Modified: 2012-03-11
Ive tried to alter this a dozen and a half times, I know I'm missing something so simple, just don't know what it is.

Im connecting to the db and grabbing the value in the colum and changing that into a variable

$color = mysql_query("SELECT cuser FROM pro_aul") or die(mysql_error());
$COLOR['usercolor'] = $color;

Open in new window


But no luck passing it along as this page is included into another page. If I put

$COLOR['usercolor'] = 'white' ;

Open in new window


or maybe (I've changed this so many times not sure which one of these had it working)
$COLOR['usercolor'] = "white";

Open in new window


In any event, once I try to actually call this info from my mysql it doesn't work.
What am I missing?

Note : the
$COLOR['usercolor'] =

Open in new window

has to stay intact. (maybe that's my downfall)
Please help
0
Comment
Question by:mimoser
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 37708339
$COLOR['usercolor'] is array syntax for an array variable with the key 'usercolor'.  If that's what it supposed to be, that's fine.

You are missing steps in your query though.  'mysql_query' does not return data directly but a 'resource' id that you must use to get the data.

$result = mysql_query("SELECT cuser FROM pro_aul") or die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$color = $row['cuser'];
$COLOR['usercolor'] = $color;

Open in new window

0
 

Author Closing Comment

by:mimoser
ID: 37708427
Works great, thank you very much!!!
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 37708472
You're welcome!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now