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

  • Home
  • SEARCH
  • 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 7601555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:11:32+00:00 2026-05-30T23:11:32+00:00

$result = floatval(mysql_query($query)) The above is a statement to retrieve a float value from

  • 0
$result = floatval(mysql_query($query))

The above is a statement to retrieve a float value from my database. When I print the value of result, it is always giving a round figure, for instance the correct value is suppose to be 3.5 but instead it prints 3. How do I fix this?

  • 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-30T23:11:33+00:00Added an answer on May 30, 2026 at 11:11 pm

    That’s actually wrong. mysql_query returns a RESOURCE (type name, not me yelling) not the actual result.

    Look into the documentation on the PHP MySQL API: http://php.net/mysql

    To get the actual result, you would do something like:

    $q = mysql_query($query);
    $val = mysql_result($q, 0);
    

    You may also want to look into PDO/MySQLi.

    If you’re curious how you’re actually getting a value:

    When cast to a string, the resource will be something like “Resource id #3”. floatval will then extract the 3.

    Edit: whoops, wrong mysql link.

    http://www.php.net/manual/en/ref.mysql.php is the mysql_* reference.

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

Sidebar

Related Questions

Result from SELECT statement is different from the result from SELECT inside VIEW. How
Example: result = ActiveRecord::Base.connection.execute(select 'ABC') How can I get the 'ABC' value from result
The result is always 1: $sql = 'SELECT COUNT(Vote) FROM ' . $table; $res
var result = from lr in _db.LeaveRequest join th in _db.TotalHourslu on lr.TotalHoursEffect equals
var result = from lr in _db.LeaveRequest join th in _db.TotalHourslu on lr.TotalHoursEffect equals
I had a result that i wanted (getting max value.) with using keypath feature
$selectra_result = mysql_query(SELECT * FROM `my_selectra` WHERE user_id='$user_id') or die(mysql_error()); while($row = mysql_fetch_array( $selectra_result
DECLARE @result varchar(MAX) SELECT NAME FROM Table WHERE ID = @Id I need to
I'm inserting the result set returned from a CLR stored procedure into a table
I am pulling a set of numbers from a MySQL database and am trying

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.