php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18416 Query sometimes works and sometimes not
Submitted: 2002-07-18 14:14 UTC Modified: 2002-07-20 04:02 UTC
From: haagsepatrick at hotmail dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4CVS-2002-07-18 OS: Win98
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: haagsepatrick at hotmail dot com
New email:
PHP Version: OS:

 

 [2002-07-18 14:14 UTC] haagsepatrick at hotmail dot com
Hi, 

I tried it on many PHP forums but with no answers  

I am making a login page, but as soon as I login I receive an error message saying: 
"Error in query: select username, md5(password) from tblusers where tblusers.username = 'ADMINISTRATOR' and md5(tblusers.password) = '6c84cbd30cf9350a990bad2bcc1bec5f' No Database Selected" 

The problem is the database table exsists (of courses I figured that one myself), and when I query the same query in mysql I dont recieve an error. 

This problem happens at random; sometimes I can log in, which makes the problem more frustrating 

(sometimes I also receive the following popup error:APACHE caused an invalid page fault in 
module PHP4TS.DLL at 015f:100ddfc1. 
Registers: ....) 

Here is the scource code below: 
------------------------------------------------------------------- 
<?php require_once('scripts/sessions.php'); ?> 
<?php require_once('Connections/OfficeBox.php'); ?> 

<? 

if($_POST['signal']!="") { 


$logusername = $_POST['username']; 
$logpassword = $_POST['encrypt']; 



$query = "select username, md5(password) from tblusers where tblusers.username = '$logusername' and md5(tblusers.password) = '$logpassword'"; 
$result = mysql_query($query) or die ("Error in query: $query " . mysql_error() ); 
$numrows = mysql_num_rows($result); 
if($numrows == 0) 
{ header("Location: logoninvalid.php"); 
exit; 
} 
else 
{ 
$_SESSION['sessusername'] = $logusername; 
header("Location: logonok.php"); 
exit; 
} 

mysql_close($connection); 
} 
else{ 
?> 



<?php 


<html> 
<head> 
<title>logon</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
</head> 
<SCRIPT language=JavaScript 
src="scripts/md5.js"></SCRIPT> 

<SCRIPT LANGUAGE=JavaScript> 
<!-- 
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1; 
function myFlash_DoFSCommand(command, args) { 
var argv = String(args).split(","); 
var argc = argv.length; 
var gebruiker = argv[0]; 
var wachtwoord = argv[1]; 
//alert ("You entered: " + strInput); 
document.form1.username.value = gebruiker; 
document.form1.password.value = wachtwoord; 
document.form1.encrypt.value = calcMD5(wachtwoord); 

var myFlashObj = InternetExplorer ? myFlash : document.myFlash; 
//alert ("You entered: " + args); 
} 
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) { 
document.write('<SCRIPT LANGUAGE=VBScript\> \n'); 
document.write('on error resume next \n'); 
document.write('Sub myFlash_FSCommand(ByVal command, ByVal args)\n'); 
document.write(' call myFlash_DoFSCommand(command, args)\n'); 
document.write('end sub\n'); 
document.write('</SCRIPT\> \n'); 
} 
//--> 
</SCRIPT> 
<body bgcolor="#cccccc" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> 
<div align="center"> 
<table width="100%" height="100%" border="0" align="center"> 
<tr> 
<td><div align="center"> 
<p> 
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" 
width="600" height="400" name="myFlash" id="myFlash"> 
<param name="movie" value="logon.swf"> 
<param name="quality" value="high"> 
<param name=bgcolor value=#FFFFFF> 
<embed src="logon.swf" quality="high" bgcolor=#FFFFFF pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="400" name="myFlash" swliveconnect=true> 
</embed></object> 
</p> 
<form name="form1" method="post" action="<? echo $PHP_SELF; ?>"> 
<input name="username" type="hidden" id="username"> 
<input name="password" type="hidden" id="password"> 
<input name="signal" type="hidden" id="signal" value="signal"> 
<input name="encrypt" type="hidden" id="encrypt"> 
</form> 
<p> </p> 
</div></td> 
</tr> 
</table> 
</div> 


</body> 
</html> 


<?php 

} 
?> 
--------------------------------------------------------------------------- 

My connection file looks like: 
------------------------------------------------------------------------- 
<?php 
# FileName="Connection_php_mysql.htm" 
# Type="MYSQL" 
# HTTP="true" 
$hostname_OfficeBox = "localhost"; 
$database_OfficeBox = "Systemapp"; 
$username_OfficeBox = "root"; 
$password_OfficeBox = ""; 
$OfficeBox = mysql_pconnect($hostname_OfficeBox, $username_OfficeBox, $password_OfficeBox) or die(mysql_error()); 
?> 
--------------------------------------------------------------------- 

MD5 in the query is not the problem. Mysql excepts the query (I ran the query from within mysql for testpurposes) Furthermore most of the time it does except my password. 


Something about the script itself:this script encrypts(using md5) the form passwordfield through javascript. When it is encrypted it checks it with the encrypted value from the database. (so in the mysql database the password is just common and readable) 

I installed 
apache_1.3.26-win32-x86-no_src.exe 
and 
php-4.3.0-dev-zend2-win32-alpha2.zip
I am using windows98

kind regards
Patrick


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-18 14:30 UTC] sniper@php.net
Does this happen with this snapshot:

http://snaps.php.net/win32/php4-win32-latest.zip

(make sure you replace ALL the files from previous install with the files found in this package! php4ts.dll being the most important one)

 [2002-07-20 04:02 UTC] georg@php.net
Please use mysql_select_db function before sending 
queries, or specify a table identifier in your query, when 
you don't use mysql_select_db.

Note: You also should upgrade your mysql-server to the 
lastest  version, some win98-bugs are fixed there.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 06:01:33 2024 UTC