PHP and MYSQL newbie question!?

Andrew asks:

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)
We've taken the best and made it even better. The third edition of the best-selling PHP and MySQL Web Development has been updated to include material and code on MySQL 5, PHP 5 and on PHPs object model and validation. Through a clear, practical... (Glyde, miscellaneous)

Web Application Design and Implementation: Apache 2, PHP5, MySQL, JavaScript, and Linux/UNIX

(more details)
Web Application Design and Implementation uses a hands-on approach of the major technologies and programming languages to teach readers web development. Providing an understanding of all major aspects of web programming in order to achieve the construction of a database-driven website, the book features state-of-the-art programming languages such as HTML, JavaScript, MySQL, PHP, Apache, Linux/Unix. (Amazon.com, none)

Web Database Applications With Php and Mysql Book [Used]

(more details)
What do eBay, Amazon.com and CNN.com have in common? They're all applications that integrate large databases with the Web. The popularity (and power) of these applications stems from their accessibility and usability: thousands of users can access the... (Glyde, miscellaneous)

PHP MySQL Website Programming: Problem - Design - Solution

(more details)
PHP MySQL Website Programming: Problem - Design - Solution shows the development process for a website using a specific set of technologies: the Apache web server, the MySQL database system, and the PHP scripting language. It gives you a completely hands-on experience and guides you through the construction of a complete application-driven site from design to deployment. Each chapter in the book is broken into three parts: Problem: The authors analyze each task and identify areas that may (Amazon.com, none)

PHP with MySQL Essential Training

(more details)
Website and database assimilation is a necessity for many of today's businesses, and learning to work with PHP is key to integration success. The objective of PHP with MySQL Essential Training is to teach both new and experienced web developers the comprehensive steps for building dynamic, data-driven, interactive websites. Instructor Kevin Skoglund demonstrates the entire process of building a content management system. He starts with the basics of the PHP language (variables, arrays, loops, fu (Amazon.com, none)

PHP and MySQL Training Course by Amazing eLearning

(more details)
Amazing eLearning presents the best self-study training course for PHP and MySQL. This is an instructional training program that offers a quick and easy method for harnessing the vast potential of PHP scripting language, MySQL database and their applications. You will spend your time studying and learning the material by using our sample codes. In addition, your schedule is your own. You can study as quickly or slowly you need to. By the time you are ready to find a better job, launch a new proj (Amazon.com, none)

PHP MySQL Website Programming: Problem - Design - Solution

(more details)
PHP MySQL Website Programming: Problem - Design - Solution shows the development process for a website using a specific set of technologies: the Apache web server, the MySQL database system, and the PHP scripting language. It gives you a completely hands-on experience and guides you through the construction of a complete application-driven site from design to deployment. Each chapter in the book is broken into three parts: Problem: The authors analyze each task and identify areas that may (Amazon.com, none)

Web Application Design and Implementation: Apache 2, PHP5, MySQL, JavaScript, and Linux/UNIX (Quantitative Software Engineering Series)

(more details)
Web Application Design and Implementation uses a hands-on approach of the major technologies and programming languages to teach readers web development. Providing an understanding of all major aspects of web programming in order to achieve the construction of a database-driven website, the book features state-of-the-art programming languages such as HTML, JavaScript, MySQL, PHP, Apache, Linux/Unix. (Amazon.com, none)

PHP and MySQL Manual: Simple, yet Powerful Web Programming (Springer Professional Computing)

(more details)
PHP is becoming the language of choice for Web development, in particular for e-Commerce and on-line database systems. PHP is open source software and easy to install, and with the growth of broadband connections in the home means that more and more people can set up their own personal web servers and create their own on-line applications. Covering all the latest features and functions of PHP including the use of object-oriented programming, this book explains how to use PHP to its full extent. (Amazon.com, none)

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)
Offering accumulated observations of interviews with hundreds of job candidates, these books provide useful insights into which characteristics make a good IT professional. These handy guides each have a complete set of job interview questions and provide a practical method for accurately assessing the technical abilities of job candidates. The personality characteristics of successful IT professionals are listed and tips for identifying candidates with the right demeanor are included. Methods f (Amazon.com, none)

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)
Create PHP projects that grab and mix data from the likes of Google Maps, Flickr, Amazon, YouTube, MSN Search, Yahoo!, Last.fm, the Internet UPC Database, not to mention the California Highway Patrol Traffic service! A mashup is a web page or application that combines data from two or more external online sources into an integrated experience. This book is your entryway to the world of mashups and Web 2.0. You will create PHP projects that grab data from one place on the Web, mix it up with (Amazon.com, none)

"Beyond The Newbie" - Getting Past The Newbie Stage Of Internet Marketing!

(more details)
"Are You Ready To Breakthrough The Newbie Trap And Start Making The Six Figure Income You Expected When You Started?" If you currently consider yourself to be a marketing newbie, then you need a change. No one is going to look at you as anything but a green know-nothing unless you project an image of respect and accomplishment. You'll learn how to do that within the first ten pages of Beyond The Newbie. If you are someone who is committed to moving to the next level, you need to realize that it (Amazon.com, none)

PHP Reference: Beginner to Intermediate PHP5

(more details)
A collection of over 250 PHP functions with clear explanations in language anyone can understand, followed with as many examples as it takes to understand what the function does and how it works. This book includes numerous additional tips, the basics of PHP, MySQL query examples, regular expressions syntax, and two indexes to help you find information faster: a common language index and a function index. When the internet is not around or you want a simpler explanation along with all the techni (Amazon.com, none)

php|architect's Zend PHP 5 Certification Study Guide

(more details)
Zend's new PHP 5 Certification Exam represent an excellent tool for professional PHP developers who want to distinguish themselves in their field. php|architect's Zend PHP 5 Certification Study Guide, edited and produced by the publishers of php|architect magazine, provides the most comprehensive and thorough preparation tool for developers who wish to take the exam. This book provides complete coverage of every topic that is part of the exam, including: ? PHP Basics ? Funct (Amazon.com, none)

php|architect's PHP Job Hunter's Handbook

(more details)
Learn the secrets to landing that perfect PHP job and managing your PHP career with this comprehensive job hunting guide from php|architect. As the only one of its kind, this book is the job reference for any PHP developer, consultant, or even those looking to get in to the PHP job market. Written by the man behind Webdevradio and long time programmer, Michael Kimsal, this book covers just about everything you'll need to know, including: - Finding a Full Time Job - Training and Certificat (Amazon.com, none)

MySQL Administrator's Guide

(more details)
This is the eBook version of the printed book. If the print book includes a CD-ROM, this content is not included within the eBook version. If you are not already one of the 4 million plus users of the MySQL database, you will want to become one after reading this book. MySQL Administrator's Guide is the official guide to installing, administering and working with MySQL 5.0 and MySQL databases. Starting with the basics, you will learn to store, manage and retrieve data in a MySQL database and to (Amazon.com, none)

MySQL Database Design and Tuning

(more details)
This is the eBook version of the printed book. If the print book includes a CD-ROM, this content is not included within the eBook version.The authoritative, hands-on guide to advanced MySQL programming and administration techniques for high performance is here. MySQL Database Design and Tuning is the only guide with coverage of both the basics and advanced topics, including reliability, performance, optimization and tuning for MySQL. This clear, concise and unique source for the most reliable My (Amazon.com, none)

MySQL Tutorial

(more details)
This is the eBook version of the printed book. If the print book includes a CD-ROM, this content is not included within the eBook version. A concise introduction to the fundamentals of working with MySQL. MySQL is an open-source relational database management system that is rapidly growing in popularity. Known for its speed, reliability, and ease of use, MySQL has proven itself to be particularly well suited both for beginners and for experienced developers to create sophisticated database-back (Amazon.com, none)

MySQL: Essential Skills

(more details)
An introductory look into the most popular open source database. Get step-by-step instruction from installing MySQL, manipulating it, and basic reporting, to advanced reporting, interfacing programs, and backups. An accessible introduction to a powerful database, featuring progress checks, exercises, and Ask the Experts sections in each chapter. (Amazon.com, none)

MySQL Tutorial (All in One)

(more details)
A concise introduction to the fundamentals of working with MySQL. MySQL is an open-source relational database management system that is rapidly growing in popularity. Known for its speed, reliability, and ease of use, MySQL has proven itself to be particularly well suited both for beginners and for experienced developers to create sophisticated database-backed Web sites and applications. MySQL Tutorial is a clear, concise introduction to the fundamental concepts and techniques of working w (Amazon.com, none)

MySQL Database Design and Tuning (Developer's Library)

(more details)
The authoritative, hands-on guide to advanced MySQL programming and administration techniques for high performance is here. MySQL Database Design and Tuning is the only guide with coverage of both the basics and advanced topics, including reliability, performance, optimization and tuning for MySQL. This clear, concise and unique source for the most reliable MySQL performance information will show you how to: Deploy the right MySQL product for your performance needs. Set up a performance man (Amazon.com, none)

MySQL: Your visual blueprint for creating open source databases

(more details)
* Discusses the basic fundamentals including database terminology and concepts. * Offers an introduction to MySQL and the SQL language, then includes essential tasks to begin using it. * Explores the essentials of MySQL server management, providing a guide for troubleshooting problems. * Presents numerous annotated screenshots, tips and tricks. * Includes a CD-ROM with additional code examples as well as advanced examples using MySQL for UNIX and Windows, PHP for Windows and UNIX, an (Amazon.com, none)

JDBC Metadata, MySQL, and Oracle Recipes: A Problem-Solution Approach (Expert's Voice in Java)

(more details)
JDBC Metadata, MySQL, and Oracle Recipes is the only book that focuses on metadata or annotation-based code recipes for JDBC API for use with Oracle and MySQL. It continues where the authors other book, JDBC Recipes: A Problem-Solution Approach, leaves off. This new edition is also a Java EE 5-compliant book, perfect for lightweight Java database development. And it provides cut-and-paste code templates that can be immediately customized and applied in each developers application development (Amazon.com, none)

NuSphere MySQL Advantage

(more details)
NuSphere MySQL Advantage is a suite of four open-source software packages--proven, popular, and well-supported ones--that work together to run interactive, dynamic Internet sites. Far from just a straight CD-ROM distribution of publicly available software, NuSphere has done a great job of automating the packages' installation processes (the suite installs under both Windows and Linux) so the four utilities interoperate smoothly. You can also install any or all of the suite's components manually, (Amazon.com, none)

MySQL Administrator's Guide and Language Reference, 2/e

(more details)
This is the eBook version of the printed book. If the print book includes a CD-ROM, this content is not included within the eBook version. Written by the creators of MySQL and edited by one of the most highly respected MySQL authors, the MySQL Administrator's Guide and Language Reference is the official guide to installing MySQL, to setting up and administering MySQL databases, and to storing and retrieving data in these databases. This new edition combines into one book the MySQL Language Refer (Amazon.com, none)

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