Solved

Simple MySql query headache

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is there a limit to how many inner joins you should use? 4 33
AWS EC2 & RDS Instance 5 36
comma true 6 33
MySQL Warning Statements when you have a LIMIT clause. 6 30
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Creating and Managing Databases with phpMyAdmin in cPanel.
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.

810 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