php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53278 mysql_result() can't return ''
Submitted: 2010-11-09 14:33 UTC Modified: 2010-11-09 15:17 UTC
From: consatan at gmail dot com Assigned:
Status: Not a bug Package: Apache2 related
PHP Version: Irrelevant OS: win 2003
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: consatan at gmail dot com
New email:
PHP Version: OS:

 

 [2010-11-09 14:33 UTC] consatan at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.mysql-result
---

Test script:
---------------
<?php
  // my php version:5.3.1
  $conn = mysql_connect("127.0.0.1", "root", "root") or die(mysql_error());
  mysql_select_db("mydb", $conn) or die(mysql_error());
  $query = mysql_query("SELECT `desc` FROM `user` WHERE `id`=2", $conn) or die(mysql_error());
  $desc = mysql_result($query, 0, 0) or die(mysql_error());
  echo "no output<br />";
  echo $desc;
?>

Expected result:
----------------
I think it must return a string '', may be $desc = '';

The fllowing is test database.

CREATE TABLE `user` (
  `id` int(4) NOT NULL AUTO_INCREMENT,
  `name` varchar(20) NOT NULL,
  `desc` tinytext DEFAULT NULL,
  PRIMARY KEY(`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

INSERT INTO `user` VALUES
('u1', ''),
('u2', NULL);


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-09 14:36 UTC] consatan at gmail dot com
I'm sorry!
The test db data is

CREATE TABLE `user` (
  `id` int(4) NOT NULL AUTO_INCREMENT,
  `name` varchar(20) NOT NULL,
  `desc` tinytext DEFAULT NULL,
  PRIMARY KEY(`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

INSERT INTO `user` VALUES
('u1', NULL),
('u2', '');
 [2010-11-09 15:04 UTC] consatan at gmail dot com
I am sorry!!
I found that I am wrong, I'm not supposed to add extra "or die(mysql_error())" behind "mysql_result()".

thx google translate
 [2010-11-09 15:05 UTC] consatan at gmail dot com
-Status: Open +Status: Closed
 [2010-11-09 15:05 UTC] consatan at gmail dot com
I am sorry!!
I found that I am wrong, I'm not supposed to add extra "or die(mysql_error())" behind "mysql_result()".

thx google translate!
 [2010-11-09 15:17 UTC] johannes@php.net
-Status: Closed +Status: Bogus
 [2010-11-09 15:17 UTC] johannes@php.net
user error -> bogus
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 10:01:29 2024 UTC