|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7301 Error in msql_result: reproducible
Submitted: 2000-10-17 23:25 UTC Modified: 2001-08-18 12:55 UTC
From: afan dot remove_this_spamguard at jeo dot net Assigned:
Status: Closed Package: mSQL related
PHP Version: 4.0.3pl1 OS: RedHat Linux 6.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: afan dot remove_this_spamguard at jeo dot net
New email:
PHP Version: OS:


 [2000-10-17 23:25 UTC] afan dot remove_this_spamguard at jeo dot net
A piece of code worked perfectly with PHP3/Apache1.3.9/msql-2..11

I tried it with PHP4/Apache_1.3.14/msql-2.0.11 and got
sporadic crashes - I found out that:
  a) You have an msql database with a value in a row blank,
     e.g. ('asdf',1,'',,...) 
  b) you have a SELECT * statement 
     $sql="SELECT * from table where ... ORDER BY ..."
     $result = msql($DB,$sql)
     while ($row = msql_fetch_row($result) ) {
  c) the FIRST row returned contains a value that is blank 
  when php hits the msql_fetch_row($result) line, 
  PHP returns nothing and gives an error in the log
file like: 
  child pid 9346 exit signal Segmentation Fault

HOWEVER, if the first row returned does not have a 
blank element in the row, then it seems to work ok.
I tried variations with 
msql_result(), msql_connect, and msql_pconnect as well
but all gave me the same problem.
Relevent facts?: 
In running "make" I get 
 gcc .... -I/usr/local/Hughes/include .... -c php_msql.c -fPIC -DPIC -o php_msql.lo
 php_msql.c:189 warning: int format, long int (arg 4)
 php_msql.c:191 warning: int format, long int (arg 4)
 php_msql.c:196 warning: int format, long int (arg 4)
 php_msql.c:198 warning: int format, long int (arg 4)

I used the stock php.ini.dist file 

Thanks in advance - PHP is great!

Afan Ottenheimer


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-20 13:22 UTC] afan dot remove_this_spamguard at jeo dot net
I pared down the code and the data to the minium while
still getting the crash. Below is the code and the 
msqldump. I think it is the NULL that is causing the 
problem and not a blank entry.

$database = "foobar";
$sql ="SELECT * FROM events WHERE ev_day='18-Oct-2000' ORDER BY typ, srttm";
$result = msql($database,$sql);
$num_rows = msql_numrows($result);

$i = 0;
while ($i < $num_rows) {

    $aff = msql_result($result,$i,"aff");
	$sql_info = "SELECT show_provider_info,provider_serial_id FROM Providers where user_name = '$aff' LIMIT 1";
	echo "DEBUG: $sql_info: $num_rows<br>";

	$result_info = msql($database,$sql_info);
	echo "DEBUG_result: $result_info<br>";
	$show_info = msql_result($result_info,0,"show_provider_info") ;
	$this_provider = msql_result($result_info,0,"provider_serial_id") ;
	echo msql_error();

	echo "DEBUG: '$show_info', '$this_provider', '$aff'<br>\n";
	if ($i == 1) {  //In this demo there are 3 entries
		exit;	//If it gets to the third($i=2) the 
	}		//program crashes w/out fail.
	if ($show_info == 1) { //CRASHES HERE
		echo "HI";

Data in database:
# mSQL Dump 
# Host: localhost    Database: foobar
# Table structure for table 'events'
DROP TABLE events \g
  id CHAR(31),
  ev_day DATE,
  srttm CHAR(8),
  endtm CHAR(8),
  group_id INT,
  typ CHAR(25),
  aff CHAR(30),
  title CHAR(30),
  descr CHAR(200)
) \g

# Dumping data for table 'events'

INSERT INTO events  VALUES ('940868200264760','18-Oct-2000','12:00 pm','1:00 pm',2,'Lunch','Slovak','Learn At Lunch','learn blah blah')\g
INSERT INTO events  VALUES ('96463942510743346','18-Oct-2000','','',2,'Other Event','Celebration Belle','Big Band Cruises','blah blah')\g
INSERT INTO events  VALUES ('965228863119070','18-Oct-2000','','',2,'Other Event','Celebration Belle','Daylong Cruise','blah blah')\g

# Table structure for table 'Providers'
DROP TABLE Providers \g
CREATE TABLE Providers (
  provider_serial_id INT,
  user_name CHAR(30),
  provider_password CHAR(14),
  provider_group_id INT,
  provider_email CHAR(35),
  permissions INT,
  provider_address1 CHAR(30),
  provider_address2 CHAR(30),
  provider_city CHAR(20),
  provider_state CHAR(2),
  provider_zip CHAR(10),
  provider_phone CHAR(12),
  provider_url CHAR(33),
  provider_info CHAR(200),
  show_provider_info INT
) \g

CREATE UNIQUE  INDEX idx_provider_id ON Providers (
) \g


# Dumping data for table 'Providers'

INSERT INTO Providers  VALUES (53,'Slovak','erased3',2,'',NULL,'','','','','','','','',0)\g
INSERT INTO Providers  VALUES (172,'Celebration Belle','erased4',2,'xxx',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)\g

 [2000-12-12 18:28 UTC]
This is duplicate of #6827.

 [2001-08-18 12:55 UTC]
Fixed in the CVS
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Jan 21 01:03:33 2022 UTC