PHP and MYSQL newbie question!?
Question
Hi im pretty new to this so hopefully should be pretty easy to answer...
Basically I want to store the output from an SQL statement in a variable, but im not quite sure of the syntax that need to be used. My SQL statement is:
SELECT f_name FROM auth_users WHERE username = 'smithy22'
This should return the name David. David is what I want to store in a variable, so how do I go about doing this? I need to do something like this...
$first_name = SELECT f_name from auth_users where username = 'smithy22';
Anyone have any ideas? Thanks
hi dr_bucks, thanks for your answer, but its the PHP code for storing the output in a variable that I need. The MYSQL statement I have produces the output I require.
Answer
mysql_connect("localhost", "dbusername", "dbpassword") or die ("Could not connect to database");
mysql_select_db("dbname") or die ("Could not select database");
$result = mysql_query("SELECT f_name FROM auth_users WHERE username = 'smitty22'");
while($row = mysql_fetch_array($result))
{
echo $row[f_name] . "";
}
Related Products
Php And Mysql Web Development Book [Used]
(more details)Web Application Design and Implementation: Apache 2, PHP5, MySQL, JavaScript, and Linux/UNIX
(more details)Web Database Applications With Php and Mysql Book [Used]
(more details)PHP MySQL Website Programming: Problem - Design - Solution
(more details)PHP with MySQL Essential Training
(more details)PHP and MySQL Training Course by Amazing eLearning
(more details)PHP MySQL Website Programming: Problem - Design - Solution
(more details)Web Application Design and Implementation: Apache 2, PHP5, MySQL, JavaScript, and Linux/UNIX (Quantitative Software Engineering Series)
(more details)PHP and MySQL Manual: Simple, yet Powerful Web Programming (Springer Professional Computing)
(more details)Conducting the Webmaster Job Interview: IT Manager Guide with Javascript, Java Applets, Front Page, Flash, Perl, PHP+, and DreamWeaver Interview Questions (IT Job Interview series)
(more details)PHP Web 2.0 Mashup Projects: Practical PHP Mashups with Google Maps, Flickr, Amazon, YouTube, MSN Search, Yahoo!: Create practical mashups in PHP grabbing ... MSN Search, Yahoo!, Last.fm, and 411Sync.com
(more details)"Beyond The Newbie" - Getting Past The Newbie Stage Of Internet Marketing!
(more details)PHP Reference: Beginner to Intermediate PHP5
(more details)php|architect's Zend PHP 5 Certification Study Guide
(more details)php|architect's PHP Job Hunter's Handbook
(more details)MySQL Administrator's Guide
(more details)MySQL Database Design and Tuning
(more details)MySQL Tutorial
(more details)MySQL: Essential Skills
(more details)MySQL Tutorial (All in One)
(more details)MySQL Database Design and Tuning (Developer's Library)
(more details)MySQL: Your visual blueprint for creating open source databases
(more details)JDBC Metadata, MySQL, and Oracle Recipes: A Problem-Solution Approach (Expert's Voice in Java)
(more details)NuSphere MySQL Advantage
(more details)MySQL Administrator's Guide and Language Reference, 2/e
(more details)Related Articles
- How to Trade Forex - A Newbie's Guide to Forex
If you would like to learn how to trade forex, the first thing you need to know is exactly what it is. Forex, short for foreign exchange, is the business of exchanging of one currency for another an - Trade Show Exhibitors - Tips For Newbies
Trade shows are anything but a walk in the park, even for experienced exhibitors but if you've never "experienced" one it can certainly be a daunting task. However, as big as the mountain appears yo - Top 5 Tech Faqs For Windows Newbies
So! You’ve got your brand new computer all set up after hours of reading instructions, looking at diagrams and trying to figure out which wires, connectors and ports go where. And now that you’r - Forex Trading For Newbies - Tips For Beginners
The Online forex trading business is now considered as a fast growing wing of international business. Forex trading is the world's biggest business but it is like a two edge sword. There are many fo - Best 5 Tips For a Forex Newbie
Before you set sail on your tempestuous voyage to attempt to make your living in the cut throat business of Forex trading, for all Forex Newbies, here are my top 5 Tips you Must adhere to if you do - Pitfalls To Avoid As A Newbie – Managing Yourself: Grouping
Previously I have written on budget (time and money) and also on organising your email routine. I touched on basic tools needed and would like to share a little on browsing. I see you sit up and tak - Low Cost Advertising Ideas for the Newbie Affiliate Marketer
People in the online marketing business, especially newbies tend to think of advertising as something that's a bit expensive and out of their league. Well truth be said it doesn't have to be that wa - Newbie Internet Marketer Strategy-Relevance - Are You Relevant?
Newbie Internet Marketer, today we are going to talk a little bit about relevance.If this is the first time you are hearing this term, get used to it, because this term is going to be one of the key - Day Trading Tips For Newbies
The modern world lays a great emphasis on money. It is a medium to trade goods and services. While our forefathers used the barter system for trading, we use money for trading. Today, trading is a p - A Rug Newbie?
Yes, rug as in rug. Persian rugs. Chinese rugs. Rugs of no Oriental origin but rugs nonetheless. If one day you woke up and realized that you are now officially a rug aficionado, then this is your l - Newbie's Guide To Developing Strength And Size In Bodybuilding.
Most neophytes don't know how to get started in bodybuilding they spend many years doing the wrong things before they learn what exactly the right things are. In this article I will address one of t - The Newbie's Guide to Antioxidants
The metabolization of oxygen by the body releases damaging by-products which effect cell membranes and other structures like cellular proteins, lipids and DNA. Antioxidants act as cell protectors, t - Help a Forex Newbie Day! - Forex Mini Trading
Hallelujah! Opportunities like these do not come often, so I am more than willing to put in my two cents worth in order to help out newbies in the trading business. First up: it's true that you can - Depression Glass - Tips For Newbie Collectors
For the newbie collector, the huge variety of colors and patterns of depression glass may be a bit overwhelming! Time and experience, and a good depression glass encyclopedia, will help the novice l - Joint Venture-newbies, Consider This
A Joint Venture can generate a ton of money for you. It can take your business some place it’s never been. In addition, nothing that you own will be placed at risk and you don’t even have to spe - Packing a Diaper Bag - A Guide For Newbies
As a parent you should probably know by now, that the diaper bag is both a needed friend to a mother or father; as well as a hated foe. While it is packed with everything you need to get through the - Mt Newbies Ask: “i've Graduated, Now How Do I Get My Foot In The Door?”
Copyright 2006 Cynthia Bull If you're a new medical transcriptionist looking for a job and have asked this same question, then you know that your foot must be pretty big to get through that door - Sandal Repair for Newbies
Are you a fashion freak who loves to get whirled in the massive breathtaking sky colored waves? All the trendy beach aficionados can now add feathers to their expensive, conspicuous and trendy beach - Singapore Health and Wellness Newby
While stress is unavoidable, minimizing stress or reducing it to an acceptable level is a must for health, wellness, longevity, and productivity. Stress leads to numerous physiologic effects. Stress - Affiliate Marketing For Newbies - What Excuse Do You Have For Failing at Affiliate Marketing
Affiliate Marketing is not an easy way to make a living, however, if you get it right it can be very rewarding. The problem with many newbie affiliate marketers and even experienced ones is that the - Newbie Photography Tips - First Steps For Kids
I have seen a lot of photography tips around the net and I would say that the majority are useful for the regular camera user and even to professional photographers.There are fewer Newbie Photogra - 5 Search Engine Optimization Strategies for Newbies
Search engine optimization is a lot easier than you think. Although you need to gather a certain amount of information about your site, preferably before you build your site, once you have the right - Dive Computers For Scuba Diving Newbies
Did you just get certified as an open water diver or now planning to dive recreational depths on your own? That's a good agenda for a budding recreational diving career. But before you get into the - Php Development Is Becoming Increasingly Popular
PHP simply refers to Hypertext Preprocessor and is becoming quite popular due to the wide nature of functions that it can be used for. Also, PHP development is relatively simple for newcomers to lea - Security Hole Mail Header Injection At Php
If you use PHP language to send an email (especially if using HTML form), you must take extra precautions. In the last few weeks, many have tried actively exploiting PHP scripts that use mail() func
Related Questions
- What's the best way to show limited records using PHP from a MySQL database like Yahoo! does in my mailbox?
- PHP script runs but the nothing changes in the MySQL database
- Newbie Cisco Certification Question (Security)?
- Basketball questions from a newbie?
- hmm... some newbie paintball questions.?
- New to paintball, please answer my newbie questions!?
- New to paintball, please answer my newbie questions!?
- Newbie Selling Football Helmet on Ebay, PLEASE HELP! I have Shipping and Paypal questions.?
- Newbie Selling Football Helmet on Ebay, PLEASE HELP! I have Shipping and Paypal questions.?
- Newbie Selling Football Helmet on Ebay, PLEASE HELP! I have Shipping and Paypal questions.?
- PHP : how do i redirect a page using PHP Script?
- How do you import data from an oracle database into a mysql database?
- How to overwrite / update a previous record automatically in mySQL?
- MySQL and Coldfusion Error?
- How can I get a list of all unique values from several columns in mysql?
- Newby with septic system, alarm has sounded three times this month. Help.?
- Newbie installing Linux on a Acer Aspire 5610z?
- hello, im a newbie to projectors. Whats a good model around the 500$ range w/ cheap bulbs, for comp. n movies
- Star trail photography, request from a newbie?
- Star trail photography, request from a newbie?
- Star trail photography, request from a newbie?
- Night Photography Newbie?
- My 35mm semi-wide lens is mounted to a 35mm M3 Rangefinder that uses 35mm roll film. Confusing for newbie?
- My 35mm semi-wide lens is mounted to a 35mm M3 Rangefinder that uses 35mm roll film. Confusing for newbie?
- My 35mm semi-wide lens is mounted to a 35mm M3 Rangefinder that uses 35mm roll film. Confusing for newbie?






















