Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Simple MySql query headache

Posted on 2012-03-11
3
Medium Priority
?
276 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 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 84

Expert Comment

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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
The viewer will learn how to count occurrences of each item in an array.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

715 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