Bug #18416 Updated: Query sometimes works and sometimes not
| From: | sniper@php.net | Date: | Thu, 18 Jul 2002 18:31:15 +0000 |
| Subject: | Bug #18416 Updated: Query sometimes works and sometimes not | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-14552@lists.php.net to get a copy of this message | ||
ID: 18416
Updated by: sniper@php.net
Reported By: haagsepatrick@hotmail.com
Status: Feedback
-Bug Type: Apache related
+Bug Type: MySQL related
Operating System: Win98
PHP Version: 4CVS-2002-07-18
Previous Comments:
------------------------------------------------------------------------
[2002-07-18 14:30:58] 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-18 14:14:50] haagsepatrick@hotmail.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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18416&edit=1