php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #665 getting 0 returned by MySQL connection
Submitted: 1998-08-19 05:32 UTC Modified: 1998-08-19 11:55 UTC
From: tom at atari dot co dot uk Assigned:
Status: Closed Package: MySQL related
PHP Version: 3.0.3 OS: Windows NT
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tom at atari dot co dot uk
New email:
PHP Version: OS:

 

 [1998-08-19 05:32 UTC] tom at atari dot co dot uk
When I use the following piece of php, I am informed that 
'0 is not a MySQL result index'. 
I understand the error message, but the same piece of code works on my Unix box... can someone tell me what wrong?

Thanks,
Tom Buck.

Extract:

mysql_connect($db, $user, $passw);
$sql = "select name, address, from clients where name like '$name%'";
$ine = mysql('barbour', $sql);
while ($arow = mysql_fetch_row($ine)) {
...
}

My PHP.ini file:

[PHP_3]

;;;;;;;;;;;;;;;;;;;;
; Language Options ;
;;;;;;;;;;;;;;;;;;;;

engine			=	On	
short_open_tag	=	On	
precision		=	14	
y2k_compliance	=	Off	
; Safe Mode
safe_mode		=	Off
safe_mode_exec_dir	=

highlight.string	=	#DD0000
highlight.comment	=	#FF8000
highlight.keyword	=	#007700
highlight.bg		=	#FFFFFF
highlight.default	=	#0000BB
highlight.html		=	#000000


;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 60     
memory_limit = 8388608		


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

error_reporting	=	7
display_errors	=	On	
log_errors		=	Off	
track_errors	=	Off	
;error_prepend_string = "<font color=ff0000>"   
;error_append_string = "</font>"                
;error_log	=	filename	
;error_log	=	syslog		
warn_plus_overloading	=	Off		


;;;;;;;;;;;;;;;;;
; Data Handling ;
;;;;;;;;;;;;;;;;;
magic_quotes_gpc	=	On		
magic_quotes_runtime=	Off		
magic_quotes_sybase	=	Off		
track_vars			=	On		

auto_prepend_file	=
auto_append_file	=


;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;
include_path	=                   
doc_root		=					
user_dir		=					
upload_tmp_dir	=	\winnt\temp	
extension_dir	=	./				




;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;

[Syslog]
define_syslog_variables	= Off	


[mail function]
SMTP			=			
sendmail_from	=	me@localhost.com	
sendmail_path	=						

[Debugger]
debugger.host	=	localhost
debugger.port	=	7869
debugger.enabled	=	False

[Logging]
;logging.method    = db
;logging.directory = /path/to/log/directory

[SQL]
sql.safe_mode	=	Off

[ODBC]
;uodbc.default_db		=	
;uodbc.default_user		=	
;uodbc.default_pw		=	
uodbc.allow_persistent	=	On	
uodbc.max_persistent	=	-1	
uodbc.max_links			=	-1	
uodbc.defaultlrl	=	4096	
uodbc.defaultbinmode	= 	1	


[MySQL]
mysql.allow_persistent	=	On	
mysql.max_persistent	=	-1	
mysql.max_links			=	-1	
mysql.default_port		=	3306	
mysql.default_host		=		
mysql.default_user		=		
mysql.default_password	=		

[mSQL]
msql.allow_persistent	=	On	
msql.max_persistent		=	-1	
msql.max_links			=	-1	

[PostgresSQL]
pgsql.allow_persistent	=	On	
pgsql.max_persistent	=	-1	
pgsql.max_links			=	-1	

[Sybase]
sybase.allow_persistent	=	On	
sybase.max_persistent	=	-1	
sybase.max_links		=	-1	
;sybase.interface_file	=	"/usr/sybase/interfaces"
sybase.min_error_severity	=	10	
sybase.min_message_severity	=	10	
sybase.compatability_mode	= Off	;
								

[Sybase-CT]
sybct.allow_persistent	=	On		
sybct.max_persistent	=	-1		
sybct.max_links			=	-1		
sybct.min_server_severity	=	10	
sybct.min_client_severity	=	10	

[bcmath]
bcmath.scale	=	0	

[browscap]
;browscap	=	extra/browscap.ini


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-08-19 11:55 UTC] zeev
There can be a thousand things going wrong, but the bottom
line is that the SQL query fails.  To discover what's going
on, set error_reporting all the way up before issuing the
SQL query:
error_reporting(E_ALL);

Then, make sure you check the return value from mysql()
is valid - this is always a good practice:

$ine = mysql(...);
if (!ine) {
   echo "SQL query failed:  ".mysql_error();
   exit;
}

The chances of this being a bug in PHP are very slim.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 00:01:29 2024 UTC