Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Simple MySql query headache

Posted on 2012-03-11
3
Medium Priority
?
279 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 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

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, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

877 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