Solved

Simple MySql query headache

Posted on 2012-03-11
3
270 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 83

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 83

Expert Comment

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
change password links 7 72
PHP Healthcheck 2 81
Is this error or Notice in php error log? 6 32
geting geocode of a user with using Google maps api 8 14
Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

932 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

11 Experts available now in Live!

Get 1:1 Help Now