|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-05-23 14:25 UTC] baret at email dot cz
Im using Apache 1.3.14. I have problem with ODBC_functions, but I dont know why, problems appeared without any changes in source codes (related to the ODBC_functions).
I have predefined functions for ODBC_connect, ODBC_close, ODBC_query, ODBC_Fetch_Row and ODBC_result (written below).
These functions are written in library.php, which is inherited in scripts by require.
require "library.php"
When Im using my functions, php crashes whith "premature end of script headers in c:/php/php.exe", but when Im using normal ODBC_functions, is everything allright. However it has been working normally, then "something happened" and it doesnt work.
function connect()
{
@$con = ODBC_connect("MySQL","","");
if(!$con)
{
$error=1;
include "error.php";
}
return $con;
}
function Query ($query)
{
global $conn;
return ODBC_exec($conn, $query);
}
function Fetch_row ()
{
global $result;
return ODBC_Fetch_Row($result);
}
function Result($field)
{
global $result;
return ODBC_Result($result, $field);
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 17:00:02 2025 UTC |
I probably recognized the problem, my scripts generates sql queries like this (non-problematic version): $query = "select count(*) cnt from tab01, tab11 where login='" .$login. "' and tab01.client_id = tab11.client_id and passwd=password('".$psswd."')"; I changed, so it should not be case sensitive for "login". $query = "select count(*) cnt from tab01, tab11 where login='" .strtolower($login). "' and tab01.client_id = tab11.client_id and passwd=password('".$psswd."')"; but this didnt work, i tried also to convert to lowercase before using the converted string and that was also wrong. $login = strtolower($login); and then i used the first query. So when I dont use converted strings, my functions works good, but when I use them, there is a problem described above.I probably recognized the problem, my scripts generates sql queries like this (non-problematic version): $query = "select count(*) cnt from tab01, tab11 where login='" .$login. "' and tab01.client_id = tab11.client_id and passwd=password('".$psswd."')"; I changed, so it should not be case sensitive for "login". $query = "select count(*) cnt from tab01, tab11 where login='" .strtolower($login). "' and tab01.client_id = tab11.client_id and passwd=password('".$psswd."')"; but this didnt work, i tried also to convert to lowercase before using the converted string and that was also wrong. $login = strtolower($login); and then i used the first query. So when I dont use converted strings, my functions works good, but when I use them, there is a problem described above.OK, here is the part of the script. Btw. i found, that this appears only if in query is agregate function count(*) (there are two types of query, one works good, other not) Im using MySQL 3.23.27-beta with MyODBC driver. There is table tab01 with information about clients. Script: <html> <head> <title>Welcome</title> <? function connect() { @$con = ODBC_connect("sample-MySQL","",""); if(!$con) echo "not connected"; return $con; } function close () { global $conn; ODBC_close($conn); } function Query ($query) { global $conn; return ODBC_exec($conn, $query); } function Fetch_row () { global $rslt; return ODBC_Fetch_Row($rslt); } function Result($field) { global $rslt; return ODBC_Result($rslt, $field); } if ($sent) { $conn = connect(); if ($conn) { $query = "select count(*) cnt from tab01 where login='".strtolower($login)."'"; //problematic // $query = "select * from tab01 where login='".strtolower($login)."'"; //works good $rslt = query($query); while(Fetch_row()) $logged = Result("cnt"); if ($logged) echo $login; else echo "not logged"; close(); } } ?> </head> <body> <form action="default.php"> <center> <table> <tr><td>Login: </td> <td><input value="<?echo $login?>" type="text" name="login"></td></tr> <tr><td colspan="2"><center><input type="submit" value="Submit"></center></td></tr> </table></center> <input type="hidden" name="sent" value="true"> </form> </body> </html>I've got a simple script, which creates the error: <?PHP if(isset($_GET['question'])){ $sql="SELECT id FROM pollv WHERE id='".$_GET['question']."' AND site='".siteid()."'"; $result=mysql_query($sql); $id=0; while($row=mysql_fetch_object($result)){ $id=$row->id; } vraag($id); } ?> question=1, this one is in the database. In table pollv is one question with id=1. This script is to check the question belongs to the site used.