Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1019405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:00:30+00:00 2026-05-16T11:00:30+00:00

now i use this code: $welcome_text = mysql_query(SELECT * FROM `text` WHERE `name` =

  • 0

now i use this code:

$welcome_text = mysql_query("SELECT * FROM `text` WHERE `name` = 'welcome'");
while ($row = mysql_fetch_array($welcome_text, MYSQL_ASSOC)) {
 echo $row['content'];
}

Is it possible to use it without WHILE if i know exactly which one column i need?
Something like this:

$welcome_text = mysql_query("SELECT 'content' FROM `text` WHERE `name` = 'welcome'");
echo $welcome_text;

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:00:31+00:00Added an answer on May 16, 2026 at 11:00 am

    mysql_query makes the query, returns a result set.

    mysql_fetch_array fetches the first row from the result set.

    $welcome_text = mysql_query("SELECT * FROM `text` WHERE `name` = 'welcome'");
    $row = mysql_fetch_array($welcome_text, MYSQL_ASSOC);
    echo $row['content'];
    

    Of course, you can shorten your code if you want, but this may make your code more difficult to debug and maintain.

    Verbose, clear code > one-liner ‘show-off’ code.

    Including ‘just-in-case’ checking:

    $welcome_text = mysql_query("SELECT * FROM `text` WHERE `name` = 'welcome'");
    if($row = mysql_fetch_array($welcome_text, MYSQL_ASSOC)){
        echo $row['content'];
    }
    

    Good practice to make doubly sure you have what you need before printing it.

    Finally, please make sure you sanitize user-submitted data before it goes into your database. If you’re not going to use prepared statements, at least use mysql_real_escape_string.

    Practice safe SQL, wear a prepared statement to prevent SQL Injections.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to use this code: <%= File.ReadAllText(Server.MapPath(Members/newsletters/welcome.html))%> which works great but now
Right now I can use this URL to request a Google Static Maps image
i use this method before 1 time. but Now i can not get video
In pylint I use this command --reports=n to disable the reports, but now I
This scenario comes up often, now that I use LinkToSql and the classes it
I've been fighting this problem for many hours now and could really use some
I use the wonderful jQuery-plugin Galleriffic to display image galeries. Now this works great,
I'm trying for hours now to solve this problem.. So.. I want to use
I originally used JQuery for this project, but now I'm having to use Prototype,
I have following code: SELECT q21, q21coding AS Description FROM `tresults_acme` WHERE q21 IS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.