PHP-MySQL connection for particular module

PHP-MySQL connection for particular module

am 17.06.2008 17:19:11 von bateivan

Hello,

First of all, please, have in mind that I am new in this business.

I have a problem connecting with data base in one particular module. That's
right. The rest of the modules can connect to db, update tables with new
info but this one is refusing giving me message like this:

"Warning: mysql_query() [function.mysql-query]: Access denied for user
'ODBC'@'localhost' (using password: NO) in D:\Program Files\Apache Software
Foundation\Apache2.2\htdocs\login.php on line 17

Warning: mysql_query() [function.mysql-query]: A link to the server could
not be established in
D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\login.php on
line 17"


It is a authentication module and this is the fragment of the code which is
giving me a hard time:

************************************************************ *******************
include $_SERVER['DOCUMENT_ROOT'].
'/layout.php';

switch($_REQUEST['req']){

case "validate":

$validate = mysql_query("SELECT * FROM members
WHERE username = '{$_POST['username']}'
AND password = md5('{$_POST['password']}')"
);

etc....

************************************************************ *******************

My platform is WinXP on drive F:\ (I have Win'98 on C:\) and as you can see
my program files are on D:\. All this may not be important but I listed
anyway.
It is installed Apache 2.2.6 using windows installer, PHP 5.2.6 (I just
replaced 5.2.5 hoping to fix the problem), and MySQL 5.0.45.

I am using persisten connection which should be on until you restart the
server. I have a file included in every page for connection with MySQL and
data base.
PHP manual says that "mysql_query" reuses the existing connection or try to
create one if not present (I think, according to the warning is trying to
create one).
I had been checking after each step using phpinfo() if the connection is
there and it's there but for some reason the above fragment does not work.
As I mentioned above the rest of my modules are working fine with mysql.

I checked the "php.ini" file. I compared it to "php.ini.recomended" from the
..zip distribusion package and they are almost identical exept couple of
things for error reporting.
I, also checked FAQ, mail listings and other forums but it does not seem
anybody had a similar problem.

In one of my tests I included a line for connection just before the problem
lines, as described below, and it worked but my intention is to keep such
lines in a separate files and include them in every page instead.

************************************************************ *******************
........

$link = mysql_pconnect('localhost', 'root', 'testing');


$validate = mysql_query("SELECT * FROM members
WHERE username = '{$_POST['username']}'
AND password = md5('{$_POST['password']}')"
);
etc.
************************************************************ *******************

As I metioned, this is an authentication module and, may be, that's why is
behaving diferently from the rest or I need to do some setup changes in
"php.ini" which I am not familiar with.

If anyone has had simmilar problem I would appreciate his/her input. Please,
help me resolve this mistery.

--
View this message in context: http://www.nabble.com/PHP-MySQL-connection-for-particular-mo dule-tp17915108p17915108.html
Sent from the Php - Database mailing list archive at Nabble.com.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-MySQL connection for particular module

am 17.06.2008 17:31:36 von isaak malik

------=_Part_23196_30571700.1213716696611
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

If you get an error of this kind:

"Warning: mysql_query() [function.mysql-query]: Access denied for user
'ODBC'@'localhost' (using password: NO) in D:\Program Files\Apache Software
Foundation\Apache2.2\htdocs\login.php on line 17

Warning: mysql_query() [function.mysql-query]: A link to the server could
not be established in
D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\login.php on
line 17"

It means that either your mysql conenction details are not correctly set or
the connection resource isn't accessible for your mysql functions. I suggest
you first try by replacing:

$link = mysql_pconnect('localhost', 'root', 'testing');

into:

mysql_pconnect('localhost', 'root', 'testing');

On 6/17/08, bateivan wrote:
>
>
> Hello,
>
> First of all, please, have in mind that I am new in this business.
>
> I have a problem connecting with data base in one particular module. That's
> right. The rest of the modules can connect to db, update tables with new
> info but this one is refusing giving me message like this:
>
> "Warning: mysql_query() [function.mysql-query]: Access denied for user
> 'ODBC'@'localhost' (using password: NO) in D:\Program Files\Apache
> Software
> Foundation\Apache2.2\htdocs\login.php on line 17
>
> Warning: mysql_query() [function.mysql-query]: A link to the server could
> not be established in
> D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\login.php on
> line 17"
>
>
> It is a authentication module and this is the fragment of the code which is
> giving me a hard time:
>
>
> ************************************************************ *******************
> > include $_SERVER['DOCUMENT_ROOT'].
> '/layout.php';
>
> switch($_REQUEST['req']){
>
> case "validate":
>
> $validate = mysql_query("SELECT * FROM members
> WHERE username = '{$_POST['username']}'
> AND password = md5('{$_POST['password']}')"
> );
>
> etc....
>
>
> ************************************************************ *******************
>
> My platform is WinXP on drive F:\ (I have Win'98 on C:\) and as you can see
> my program files are on D:\. All this may not be important but I listed
> anyway.
> It is installed Apache 2.2.6 using windows installer, PHP 5.2.6 (I just
> replaced 5.2.5 hoping to fix the problem), and MySQL 5.0.45.
>
> I am using persisten connection which should be on until you restart the
> server. I have a file included in every page for connection with MySQL and
> data base.
> PHP manual says that "mysql_query" reuses the existing connection or try to
> create one if not present (I think, according to the warning is trying to
> create one).
> I had been checking after each step using phpinfo() if the connection is
> there and it's there but for some reason the above fragment does not work.
> As I mentioned above the rest of my modules are working fine with mysql.
>
> I checked the "php.ini" file. I compared it to "php.ini.recomended" from
> the
> .zip distribusion package and they are almost identical exept couple of
> things for error reporting.
> I, also checked FAQ, mail listings and other forums but it does not seem
> anybody had a similar problem.
>
> In one of my tests I included a line for connection just before the problem
> lines, as described below, and it worked but my intention is to keep such
> lines in a separate files and include them in every page instead.
>
>
> ************************************************************ *******************
> .......
>
> $link = mysql_pconnect('localhost', 'root', 'testing');
>
>
> $validate = mysql_query("SELECT * FROM members
> WHERE username = '{$_POST['username']}'
> AND password = md5('{$_POST['password']}')"
> );
> etc.
>
> ************************************************************ *******************
>
> As I metioned, this is an authentication module and, may be, that's why is
> behaving diferently from the rest or I need to do some setup changes in
> "php.ini" which I am not familiar with.
>
> If anyone has had simmilar problem I would appreciate his/her input.
> Please,
> help me resolve this mistery.
>
> --
> View this message in context:
> http://www.nabble.com/PHP-MySQL-connection-for-particular-mo dule-tp17915108p17915108.html
> Sent from the Php - Database mailing list archive at Nabble.com.
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Isaak Malik
Web Developer

------=_Part_23196_30571700.1213716696611--

Re: PHP-MySQL connection for particular module

am 17.06.2008 19:59:38 von Eric

----------------------------------------------------
http://myprojects.srhost.info
eric{at}myprojects{dot}srhost{dot}info
----- Original Message -----=20
From: "bateivan"
To:
Sent: Tuesday, June 17, 2008 11:19 PM
Subject: [PHP-DB] PHP-MySQL connection for particular module


:=20
: Hello,
:=20
: First of all, please, have in mind that I am new in this business.
:=20
: I have a problem connecting with data base in one particular module. =
That's
: right. The rest of the modules can connect to db, update tables with =
new
: info but this one is refusing giving me message like this:
:=20
: "Warning: mysql_query() [function.mysql-query]: Access denied for user
: 'ODBC'@'localhost' (using password: NO) in D:\Program Files\Apache =
Software
: Foundation\Apache2.2\htdocs\login.php on line 17
:=20

This error message state that you have provided a wrong username and / =
or password
use the die also to ensure the connection was created.

: Warning: mysql_query() [function.mysql-query]: A link to the server =
could
: not be established in
: D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\login.php =
on
: line 17"
:=20
:=20
: It is a authentication module and this is the fragment of the code =
which is
: giving me a hard time:
:=20
: =
************************************************************ *************=
******
: : include $_SERVER['DOCUMENT_ROOT'].
: '/layout.php';
:=20

Let's your included page on the same directory. Say f:\webroot\docroot
As
f:\webroot\docroot\layout.php
f:\webroot\docroot\login.php

then try change the line from

include $_SERVER['DOCUMENT_ROOT'].
'/layout.php';

to

$app_root =3D './';
include ($app_root . 'layout.php');


: switch($_REQUEST['req']){=20
: =20
: case "validate":
:=20
: $validate =3D mysql_query("SELECT * FROM members
: WHERE username =3D '{$_POST['username']}'
: AND password =3D =
md5('{$_POST['password']}')"
: );
:=20
: etc....
:=20
: =
************************************************************ *************=
******
:=20
: My platform is WinXP on drive F:\ (I have Win'98 on C:\) and as you =
can see
: my program files are on D:\. All this may not be important but I =
listed
: anyway.
: It is installed Apache 2.2.6 using windows installer, PHP 5.2.6 (I =
just
: replaced 5.2.5 hoping to fix the problem), and MySQL 5.0.45.
:=20
: I am using persisten connection which should be on until you restart =
the
: server. I have a file included in every page for connection with MySQL =
and
: data base.
: PHP manual says that "mysql_query" reuses the existing connection or =
try to
: create one if not present (I think, according to the warning is trying =
to
: create one).
: I had been checking after each step using phpinfo() if the connection =
is
: there and it's there but for some reason the above fragment does not =
work.
: As I mentioned above the rest of my modules are working fine with =
mysql.
:=20
: I checked the "php.ini" file. I compared it to "php.ini.recomended" =
from the
: .zip distribusion package and they are almost identical exept couple =
of
: things for error reporting.
: I, also checked FAQ, mail listings and other forums but it does not =
seem
: anybody had a similar problem.
:=20
: In one of my tests I included a line for connection just before the =
problem
: lines, as described below, and it worked but my intention is to keep =
such
: lines in a separate files and include them in every page instead.
:=20
: =
************************************************************ *************=
******
: .......
:=20
: $link =3D mysql_pconnect('localhost', 'root', 'testing');
:=20
:=20
: $validate =3D mysql_query("SELECT * FROM members
: WHERE username =3D '{$_POST['username']}'
: AND password =3D =
md5('{$_POST['password']}')"
: );
: etc.
: =
************************************************************ *************=
******
:=20
: As I metioned, this is an authentication module and, may be, that's =
why is
: behaving diferently from the rest or I need to do some setup changes =
in
: "php.ini" which I am not familiar with.
:=20
: If anyone has had simmilar problem I would appreciate his/her input. =
Please,
: help me resolve this mistery.
:=20
: --=20
: View this message in context: =
http://www.nabble.com/PHP-MySQL-connection-for-particular-mo dule-tp179151=
08p17915108.html
: Sent from the Php - Database mailing list archive at Nabble.com.
:=20
:=20
: --=20
: PHP Database Mailing List (http://www.php.net/)
: To unsubscribe, visit: http://www.php.net/unsub.php
:

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-MySQL connection for particular module

am 18.06.2008 01:51:53 von dmagick

> It means that either your mysql conenction details are not correctly set or
> the connection resource isn't accessible for your mysql functions. I suggest
> you first try by replacing:
>
> $link = mysql_pconnect('localhost', 'root', 'testing');
>
> into:
>
> mysql_pconnect('localhost', 'root', 'testing');

Why? How is that going to help fix the problem?

Personally I'd say to *not* use persistent connections as it will cause
you problems later.

Use a normal connection:

$link = mysql_connect($server, $user, $pass);

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-MySQL connection for particular module

am 18.06.2008 02:09:59 von legnakarlos

excuseme but, you can access by terminal? [shell]

ODBC is the user? or is a ODBC database?

Please answer me and i can help you.

**Excuse me my english is bad. :(

El 17/06/2008, a las 06:51 p.m., Chris escribi=F3:

>
>> It means that either your mysql conenction details are not =20
>> correctly set or
>> the connection resource isn't accessible for your mysql functions. =20=

>> I suggest
>> you first try by replacing:
>>
>> $link =3D mysql_pconnect('localhost', 'root', 'testing');
>>
>> into:
>>
>> mysql_pconnect('localhost', 'root', 'testing');
>
> Why? How is that going to help fix the problem?
>
> Personally I'd say to *not* use persistent connections as it will =20
> cause
> you problems later.
>
> Use a normal connection:
>
> $link =3D mysql_connect($server, $user, $pass);
>
> --=20
> Postgresql & php tutorials
> http://www.designmagick.com/
>
> --=20
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-MySQL connection for particular module

am 18.06.2008 13:23:30 von isaak malik

------=_Part_692_18641239.1213788210819
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Because then the connection resource isn't stored in the $link variable and
you will be able to use the mysql functions without passing that variable to
each function.

On Wed, Jun 18, 2008 at 1:51 AM, Chris wrote:

>
> > It means that either your mysql conenction details are not correctly set
> or
> > the connection resource isn't accessible for your mysql functions. I
> suggest
> > you first try by replacing:
> >
> > $link = mysql_pconnect('localhost', 'root', 'testing');
> >
> > into:
> >
> > mysql_pconnect('localhost', 'root', 'testing');
>
> Why? How is that going to help fix the problem?
>
> Personally I'd say to *not* use persistent connections as it will cause
> you problems later.
>
> Use a normal connection:
>
> $link = mysql_connect($server, $user, $pass);
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>



--
Isaak Malik
Web Developer

------=_Part_692_18641239.1213788210819--

Re: PHP-MySQL connection for particular module

am 18.06.2008 13:33:00 von isaak malik

------=_Part_723_16569272.1213788780284
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

You're very welcome, I understand that you need a solution which allows you
to keep using the connection this way.

I doubt that your php.ini is the cause so I'll suggest the following:

Try executing your MySQL queries by passing the $link variable to the
function as the connection resource:

mysql_query("SELECT...", $link);

Something that also might cause it is that you use (include|require)_once
and that this module doesn't have access to the connection resource, if this
is the case change it into include|require and see if that solves your
issue. If not then could you please post some example code of your module if
possible so we can be more helpful?

Also be sure that you global $link; it in functions (I don't know if this
required since I didn't use it this way for a long while).

Could you also please answer to the list instead of directly to me as this
might also be informative for others.

On Tue, Jun 17, 2008 at 10:49 PM, wrote:

> Thank you Isaak for interest in my subject.
>
> I have my connection set in a separate file which is included into the
> page. All my modules work except this one.
> When I use the following line
> $link = mysql_pconnect('localhost', 'root', 'testing');
> actually, my module starts working which is a redundant line as long as I
> have all this set in my include file.
> The thing is that I would like to keep this code in an included file for
> clearness and readability and make it work.
>
> Any idea why this is happening only to this module. May be, it requires
> change of some settings in php.ini or I am doing something wrong but the
> code is actually working when I introduce the line above.
> Tanx
>
> Isaak Malik-3 wrote:
> >
> > If you get an error of this kind:
> >
> > "Warning: mysql_query() [function.mysql-query]: Access denied for user
> > 'ODBC'@'localhost' (using password: NO) in D:\Program Files\Apache
> > Software
> > Foundation\Apache2.2\htdocs\login.php on line 17
> >
> > Warning: mysql_query() [function.mysql-query]: A link to the server could
> > not be established in
> > D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\login.php on
> > line 17"
> >
> > It means that either your mysql conenction details are not correctly set
> > or
> > the connection resource isn't accessible for your mysql functions. I
> > suggest
> > you first try by replacing:
> >
> > $link = mysql_pconnect('localhost', 'root', 'testing');
> >
> > into:
> >
> > mysql_pconnect('localhost', 'root', 'testing');
> >
> > On 6/17/08, bateivan wrote:
> >>
> >>
> >> Hello,
> >>
> >> First of all, please, have in mind that I am new in this business.
> >>
> >> I have a problem connecting with data base in one particular module.
> >> That's
> >> right. The rest of the modules can connect to db, update tables with new
> >> info but this one is refusing giving me message like this:
> >>
> >> "Warning: mysql_query() [function.mysql-query]: Access denied for user
> >> 'ODBC'@'localhost' (using password: NO) in D:\Program Files\Apache
> >> Software
> >> Foundation\Apache2.2\htdocs\login.php on line 17
> >>
> >> Warning: mysql_query() [function.mysql-query]: A link to the server
> could
> >> not be established in
> >> D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\login.php
> on
> >> line 17"
> >>
> >>
> >> It is a authentication module and this is the fragment of the code which
> >> is
> >> giving me a hard time:
> >>
> >>
> >>
> ************************************************************ *******************
> >> > >> include $_SERVER['DOCUMENT_ROOT'].
> >> '/layout.php';
> >>
> >> switch($_REQUEST['req']){
> >>
> >> case "validate":
> >>
> >> $validate = mysql_query("SELECT * FROM members
> >> WHERE username = '{$_POST['username']}'
> >> AND password = md5('{$_POST['password']}')"
> >> );
> >>
> >> etc....
> >>
> >>
> >>
> ************************************************************ *******************
> >>
> >> My platform is WinXP on drive F:\ (I have Win'98 on C:\) and as you can
> >> see
> >> my program files are on D:\. All this may not be important but I listed
> >> anyway.
> >> It is installed Apache 2.2.6 using windows installer, PHP 5.2.6 (I just
> >> replaced 5.2.5 hoping to fix the problem), and MySQL 5.0.45.
> >>
> >> I am using persisten connection which should be on until you restart the
> >> server. I have a file included in every page for connection with MySQL
> >> and
> >> data base.
> >> PHP manual says that "mysql_query" reuses the existing connection or try
> >> to
> >> create one if not present (I think, according to the warning is trying
> to
> >> create one).
> >> I had been checking after each step using phpinfo() if the connection is
> >> there and it's there but for some reason the above fragment does not
> >> work.
> >> As I mentioned above the rest of my modules are working fine with mysql.
> >>
> >> I checked the "php.ini" file. I compared it to "php.ini.recomended" from
> >> the
> >> .zip distribusion package and they are almost identical exept couple of
> >> things for error reporting.
> >> I, also checked FAQ, mail listings and other forums but it does not seem
> >> anybody had a similar problem.
> >>
> >> In one of my tests I included a line for connection just before the
> >> problem
> >> lines, as described below, and it worked but my intention is to keep
> such
> >> lines in a separate files and include them in every page instead.
> >>
> >>
> >>
> ************************************************************ *******************
> >> .......
> >>
> >> $link = mysql_pconnect('localhost', 'root', 'testing');
> >>
> >>
> >> $validate = mysql_query("SELECT * FROM members
> >> WHERE username = '{$_POST['username']}'
> >> AND password = md5('{$_POST['password']}')"
> >> );
> >> etc.
> >>
> >>
> ************************************************************ *******************
> >>
> >> As I metioned, this is an authentication module and, may be, that's why
> >> is
> >> behaving diferently from the rest or I need to do some setup changes in
> >> "php.ini" which I am not familiar with.
> >>
> >> If anyone has had simmilar problem I would appreciate his/her input.
> >> Please,
> >> help me resolve this mistery.
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/PHP-MySQL-connection-for-particular-mo dule-tp17915108p17915108.html
> >> Sent from the Php - Database mailing list archive at Nabble.com.
> >>
> >>
> >>
> >> --
> >> PHP Database Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> > --
> > Isaak Malik
> > Web Developer
> >
> >
> Quoted from:
>
> http://www.nabble.com/PHP-MySQL-connection-for-particular-mo dule-tp17915108p17916593.html
>
>
--
Isaak Malik
Web Developer

------=_Part_723_16569272.1213788780284--

Re: PHP-MySQL connection for particular module

am 18.06.2008 21:04:14 von bateivan

Thank you, Chris,

I tried your suggestion using regular connection. Unfortunately, I got the
same result.
See my reply to Isaak,s reply where I am going to post portion of my code to
visualize what I am talking about.

Thanx again


chris smith-9 wrote:
>
>
>> It means that either your mysql conenction details are not correctly set
>> or
>> the connection resource isn't accessible for your mysql functions. I
>> suggest
>> you first try by replacing:
>>
>> $link = mysql_pconnect('localhost', 'root', 'testing');
>>
>> into:
>>
>> mysql_pconnect('localhost', 'root', 'testing');
>
> Why? How is that going to help fix the problem?
>
> Personally I'd say to *not* use persistent connections as it will cause
> you problems later.
>
> Use a normal connection:
>
> $link = mysql_connect($server, $user, $pass);
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

--
View this message in context: http://www.nabble.com/PHP-MySQL-connection-for-particular-mo dule-tp17915108p17989584.html
Sent from the Php - Database mailing list archive at Nabble.com.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-MySQL connection for particular module

am 18.06.2008 21:38:56 von bateivan

Hello,

To answer these qwestions:
1. I am using "include" in my code.
2. About the "$link =3D mysql_connect('localhost', 'root', 'testing');"
variable. I can just include this line before mysql_query function and it
works even without entering into mysql_query the "$link" variable. (Like th=
e
connection is waking up).
3.My php.ini register_globals is off as suggested for new versions of PHP
but include file should work instead according to the manual.
4. I am posting some of my code to compare. Module "carmade.php" works v.s.
"login.php" which does not. Also, I am posting my "database.php" which is
establishing the connection and is included in every page through
"layout.php"->"common.php"->"database.php".

carmade.php:
include $_SERVER['DOCUMENT_ROOT'].
'/layout.php';

// Quick Login session check =20
login_check();
=20
switch($_REQUEST['req']){
// Insert Case
case "create_carmade":
myheader("Добавяне н=D0=
° автомобилн и =D0=
¼Ð°Ñ€ÐºÐ=B8 в списък=D0=
°");
=20
// Double check form posted values are there
// before performing INSERT query
if(!$_POST['car_descr']){
echo '

Липсва =D0=
¸Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸ÑÑ ‚Ñ=8F =D0=
¾Ñ=82 формата!

'.
'

Моля, изп=D0=
¾Ð»Ð·Ð²Ð°Ð¹Ñ‚Ð=B5 буто=D0=
½Ð°'.
'Назад и въве=D0=
´ÐµÑ‚Ð=B5 данните о=D1=
‚новÐ=BE!

';
footer();
exit();
}
=20
// Insert Query
$sql =3D mysql_query("INSERT INTO carmade
(car_descr)
VALUES('{$_POST['car_descr']}')");
=20
// Insert query results =20
if(!$sql){
echo "Грешка при =D0=
²ÑŠÐ²ÐµÐ¶Ð´Ð°Ð½Ð=B5 на д=D0=
°Ð½Ð½Ð¸Ñ‚Ð=B5:".mysql_error();
} else {
=20
echo '

Маркат=D0=
° "'.$_POST['car_descr'].
'"е въведена
с=
номер:'.mysql_insert_id();
echo '
/admin/carmade.php?req=3Dnew_carmade Ис=D0=
ºÐ°Ñ‚Ð=B5 ли да'.
=09'въведете др=D1=
ƒÐ³Ð° марка? ';
}=20
break;
=20
// Create car made form case
case "new_carmade":
myheader("Въвеждан=D 0=B5 =D0=
½Ð° нова автомо=D0=
±Ð¸Ð»Ð½Ð° марка");
include $_SERVER['DOCUMENT_ROOT'].
'/html/forms/carmade_insert.html';
footer();
break;
=20
default:
myheader("Админист=D 1€Ð=
¸Ñ€Ð°Ð½Ð=B5 на списъ=D0=
ºÐ° с автомобил=D0=
½Ð¸Ñ‚Ð=B5 марки");
include $_SERVER['DOCUMENT_ROOT'].
'/html/carmade_admin.html';
footer();
break;
=20
}
?>

login.php:
include $_SERVER['DOCUMENT_ROOT'].
'/layout.php';


switch($_REQUEST['req']){=20
=20
case "validate":

$validate =3D mysql_query("SELECT * FROM members
WHERE username =3D '{$_POST['username']}'
AND password =3D md5('{$_POST['password']}')"
);

$num_rows =3D mysql_num_rows($validate);

if($num_rows == 1){
while($row =3D mysql_fetch_assoc($validate)){
$_SESSION['login'] =3D true;
$_SESSION['userid'] =3D $row['member_id'];
$_SESSION['first_name'] =3D $row['first_name'];
$_SESSION['last_name'] =3D $row['last_name'];
$_SESSION['email_address'] =3D $row['email_address'];
=20
if($row['admin_access'] == 1){
$_SESSION['admin_access'] =3D true;
}
$login_time =3D mysql_query("UPDATE members
SET last_login=3Dnow()
WHERE id=3D'{$row['id']}'");
}
header("Location: /loggedin.php");
} else {
myheader("Входът в ад=D0=
¼Ð¸Ð½Ð¸ÑÑ‚ратиР²Ð½Ð°=
та зона е неусп=
ешен!");
echo '

Входът в=
страницата не =
е успешен!

';
echo '

Провере=
те потребител =
ското си '.
'име и парола=
та си и опитайт=
е пак или се '.
'обадете на а=
дминистрат ор=D0=
°.

';
footer();
}
break;

default:
myheader("Вход!");
include $_SERVER['DOCUMENT_ROOT'].
'/html/forms/login_form.html';
footer();
break;
}
?> =20

database.php:
$link =3D mysql_pconnect('localhost','root','testing');
$set =3D mysql_query('SET NAMES CP1251');
$set =3D mysql_query('SET_COLLATION=3DCP1251_GENERAL_CI');
mysql_select_db('samek_db', $link) or die(mysql_error());

?>

common.php:

// Include Meta Content Class
include $_SERVER['DOCUMENT_ROOT'].'/classes/clsMetaContent.php';

// Include Email Class
include $_SERVER['DOCUMENT_ROOT'].'/classes/clsEmail.php';

// Include Database Connection File
include $_SERVER['DOCUMENT_ROOT'].'/includes/database.php';

// Include Session File
include $_SERVER['DOCUMENT_ROOT'].'/includes/session.php';

?>

Thank you for your help


You're very welcome, I understand that you need a solution which allows you
to keep using the connection this way.

I doubt that your php.ini is the cause so I'll suggest the following:

Try executing your MySQL queries by passing the $link variable to the
function as the connection resource:

mysql_query("SELECT...", $link);

Something that also might cause it is that you use (include|require)_once
and that this module doesn't have access to the connection resource, if thi=
s
is the case change it into include|require and see if that solves your
issue. If not then could you please post some example code of your module i=
f
possible so we can be more helpful?

Also be sure that you global $link; it in functions (I don't know if this
required since I didn't use it this way for a long while).

Could you also please answer to the list instead of directly to me as this
might also be informative for others.

--=20
View this message in context: http://www.nabble.com/PHP-MySQL-connection-fo=
r-particular-module-tp17915108p17990192.html
Sent from the Php - Database mailing list archive at Nabble.com.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-MySQL connection for particular module

am 18.06.2008 21:47:35 von Evert Lammerts

UGFzdGViaW4gd29ya3MgbG90cyBiZXR0ZXIgd2hlbiB5b3UncmUgcG9zdGlu ZyBjb2RlOiB3d3cu
cGFzdGViaW4uY29tCgpJIGRvbid0IHNlZSB5b3VyIGRhdGFiYXNlLnBocCBp bmNsdWRlZCBpbiBi
b3RoIG9mIHRoZXNlIG1vZHVsZXMuIFdoZXJlCmRvIHlvdSBpbmNsdWRlIGl0 PwoKRVZlcnQKCk9u
IFdlZCwgSnVuIDE4LCAyMDA4IGF0IDk6MzggUE0sIGJhdGVpdmFu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3dy5waHAubmV0L3Vuc3ViLnBocAo+Cj4K

Re: PHP-MySQL connection for particular module

am 18.06.2008 22:29:24 von isaak malik

------=_Part_2716_4823382.1213820964859
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: base64
Content-Disposition: inline

VG8gRXZlcnQ6Cgo0LiBJIGFtIHBvc3Rpbmcgc29tZSBvZiBteSBjb2RlIHRv IGNvbXBhcmUuIE1v
ZHVsZSAiY2FybWFkZS5waHAiIHdvcmtzIHYucy4KImxvZ2luLnBocCIgd2hp Y2ggZG9lcyBub3Qu
IEFsc28sIEkgYW0gcG9zdGluZyBteSAiZGF0YWJhc2UucGhwIiB3aGljaCBp cwplc3RhYmxpc2hp
bmcgdGhlIGNvbm5lY3Rpb24gYW5kIGlzIGluY2x1ZGVkIGluIGV2ZXJ5IHBh Z2UgdGhyb3VnaAoi
bGF5b3V0LnBocCItPiJjb21tb24ucGhwIi0+ImRhdGFiYXNlLnBocCIuCgpU byBiYXRlaXZhbjoK
CkkgY2FuIG9ubHkgZ3Vlc3MgdGhhdCB0aGUgZGF0YWJhc2UucGhwIGZpbGUg aXNuJ3QgY29ycmVj
dGx5IGxvYWRlZCB2aWEKbGF5b3V0LnBocCwgZGlkIHlvdSBhbHJlYWR5IHRy eSB0byBpbmNsdWRl
IGRhdGFiYXNlLnBocCBpbnRvIHRoZSBtb2R1bGUgaW4Kd2hpY2ggaXQgd2Fz bid0IHdvcmtpbmc/
IElmIHNvIGFuZCBpdCB3b3JrcyB0aGVuIHRoZSBpc3N1ZSBpcyBwcm9iYWJs eQpjYXVzZWQgYnkg
aW5jb3JyZWN0bHkgaW5jbHVkaW5nIHRoYXQgZmlsZSwgb3RoZXJ3aXNlIGl0 IGhhcyB0byBiZSBz
b21ldGhpbmcKZWxzZS4uLgoKQW5kIHJlZ2lzdGVyX2dsb2JhbHMgYWxsb3dz IHlvdSB0byB1c2Ug
c2hvcnQgdmFyaWFibGVzIGZvciBzdXBlciBnbG9iYWwKYXJyYXlz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aGlzCj4gPiBtaWdo
dCBhbHNvIGJlIGluZm9ybWF0aXZlIGZvciBvdGhlcnMuCj4gPgo+ID4gLS0K PiA+IFZpZXcgdGhp
cyBtZXNzYWdlIGluIGNvbnRleHQ6Cj4gaHR0cDovL3d3dy5uYWJibGUuY29t L1BIUC1NeVNRTC1j
b25uZWN0aW9uLWZvci1wYXJ0aWN1bGFyLW1vZHVsZS10cDE3OTE1MTA4cDE3 OTkwMTkyLmh0bWwK
PiA+IFNlbnQgZnJvbSB0aGUgUGhwIC0gRGF0YWJhc2UgbWFpbGluZyBsaXN0 IGFyY2hpdmUgYXQg
TmFiYmxlLmNvbS4KPiA+Cj4gPgo+ID4gLS0KPiA+IFBIUCBEYXRhYmFzZSBN YWlsaW5nIExpc3Qg
KGh0dHA6Ly93d3cucGhwLm5ldC8pCj4gPiBUbyB1bnN1YnNjcmliZSwgdmlz aXQ6IGh0dHA6Ly93
d3cucGhwLm5ldC91bnN1Yi5waHAKPiA+Cj4gPgo+CgoKCi0tIApJc2FhayBN YWxpawpXZWIgRGV2
ZWxvcGVyCg==
------=_Part_2716_4823382.1213820964859--

Re: PHP-MySQL connection for particular module

am 19.06.2008 01:57:56 von dmagick

Isaak Malik wrote:
> Because then the connection resource isn't stored in the $link variable
> and you will be able to use the mysql functions without passing that
> variable to each function.

RTM again.

The link parameter is completely optional.

If you don't specify it, it uses the last connection created.

I can do this and it's perfectly valid:

$link = mysql_connect($server, $user, $pass);
if (!$link) {
die ("Unable to connect to the database server");
}

$db_selected = mysql_select_db($databasename);
if (!$db_selected) {
die("Unable to connect to the database $databasename");
}

$result = mysql_query("select 1");

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-MySQL connection for particular module

am 19.06.2008 09:12:54 von isaak malik

------=_Part_3874_5293697.1213859574336
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

My mistake then, it's been a while that I used it that way so some things do
fade away from my mind.

On Thu, Jun 19, 2008 at 1:57 AM, Chris wrote:

> Isaak Malik wrote:
> > Because then the connection resource isn't stored in the $link variable
> > and you will be able to use the mysql functions without passing that
> > variable to each function.
>
> RTM again.
>
> The link parameter is completely optional.
>
> If you don't specify it, it uses the last connection created.
>
> I can do this and it's perfectly valid:
>
> $link = mysql_connect($server, $user, $pass);
> if (!$link) {
> die ("Unable to connect to the database server");
> }
>
> $db_selected = mysql_select_db($databasename);
> if (!$db_selected) {
> die("Unable to connect to the database $databasename");
> }
>
> $result = mysql_query("select 1");
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>



--
Isaak Malik
Web Developer

------=_Part_3874_5293697.1213859574336--

Re: PHP-MySQL connection for particular module

am 19.06.2008 10:51:03 von Evert Lammerts

What you said wasn't wrong - you'd just produce a couple of warnings.
By taking away the assignment of the $link variable you're unsetting
it, meaning it will have a value equal to NULL. All of the following
should work.

[old code]
if (!($link = mysql_connect($a, $b, $c))) return;

if (!mysql_select_db($dbname)) return;

$res = mysql_query("SELECT * FROM manual;", $link);
[/old code]

[new code]
if (!mysql_connect($a, $b, $c)) return;

if (!mysql_select_db($dbname)) return;

$res = mysql_query("SELECT * FROM manual;", $link);
[/new code]

OR, optionally, to surpress the warnings:

[new code]
if (!mysql_connect($a, $b, $c)) return;

$link = null;

if (!mysql_select_db($dbname)) return;

$res = mysql_query("SELECT * FROM manual;", $link);
[/new code]

Evert

On Thu, Jun 19, 2008 at 9:12 AM, Isaak Malik wrote:
> My mistake then, it's been a while that I used it that way so some things do
> fade away from my mind.
>
> On Thu, Jun 19, 2008 at 1:57 AM, Chris wrote:
>
>> Isaak Malik wrote:
>> > Because then the connection resource isn't stored in the $link variable
>> > and you will be able to use the mysql functions without passing that
>> > variable to each function.
>>
>> RTM again.
>>
>> The link parameter is completely optional.
>>
>> If you don't specify it, it uses the last connection created.
>>
>> I can do this and it's perfectly valid:
>>
>> $link = mysql_connect($server, $user, $pass);
>> if (!$link) {
>> die ("Unable to connect to the database server");
>> }
>>
>> $db_selected = mysql_select_db($databasename);
>> if (!$db_selected) {
>> die("Unable to connect to the database $databasename");
>> }
>>
>> $result = mysql_query("select 1");
>>
>> --
>> Postgresql & php tutorials
>> http://www.designmagick.com/
>>
>
>
>
> --
> Isaak Malik
> Web Developer
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-MySQL connection for particular module

am 19.06.2008 12:30:17 von bateivan

Hello Isaak,

You've scored the bulleye! It works!
Also, I tested by including "common.php" instead of "database.php" and it
worked too.
This solution is perfect for me as I can keep my code compact and tidy.

I would, definetely, recommend this site to my fellow developers.

Thank you very much, Isaak and all the rest of the guys who took interst in
my problem.
Best regards.


Isaak Malik-3 wrote:
>=20
> To Evert:
>=20
> 4. I am posting some of my code to compare. Module "carmade.php" works
> v.s.
> "login.php" which does not. Also, I am posting my "database.php" which is
> establishing the connection and is included in every page through
> "layout.php"->"common.php"->"database.php".
>=20
> To bateivan:
>=20
> I can only guess that the database.php file isn't correctly loaded via
> layout.php, did you already try to include database.php into the module i=
n
> which it wasn't working? If so and it works then the issue is probably
> caused by incorrectly including that file, otherwise it has to be
> something
> else...
>=20
> And register_globals allows you to use short variables for super global
> arrays. Ex: $name instead of $_POST['name'], etc.
>=20
>=20
> On Wed, Jun 18, 2008 at 9:47 PM, Evert Lammerts >
> wrote:
>=20
>> Pastebin works lots better when you're posting code: www.pastebin.com
>>
>> I don't see your database.php included in both of these modules. Where
>> do you include it?
>>
>> EVert
>>
>> On Wed, Jun 18, 2008 at 9:38 PM, bateivan wrote:
>> >
>> > Hello,
>> >
>> > To answer these qwestions:
>> > 1. I am using "include" in my code.
>> > 2. About the "$link =3D mysql_connect('localhost', 'root', 'testing');=
"
>> > variable. I can just include this line before mysql_query function and
>> it
>> > works even without entering into mysql_query the "$link" variable.
>> (Like
>> the
>> > connection is waking up).
>> > 3.My php.ini register_globals is off as suggested for new versions of
>> PHP
>> > but include file should work instead according to the manual.
>> > 4. I am posting some of my code to compare. Module "carmade.php" works
>> v.s.
>> > "login.php" which does not. Also, I am posting my "database.php" which
>> is
>> > establishing the connection and is included in every page through
>> > "layout.php"->"common.php"->"database.php".
>> >
>> > carmade.php:
>> > >> > include $_SERVER['DOCUMENT_ROOT'].
>> > '/layout.php';
>> >
>> > // Quick Login session check
>> > login_check();
>> >
>> > switch($_REQUEST['req']){
>> > // Insert Case
>> > case "create_carmade":
>> > myheader("Добавяне н=
а автомобилн и =
марки в списък=
а");
>> >
>> > // Double check form posted values are there
>> > // before performing INSERT query
>> > if(!$_POST['car_descr']){
>> > echo '

Липсва=
информация тя =
от формата!

'.
>> > '

Моля, и=
зползвайте бу=
тона'.
>> > 'Назад и въ=D0=
²ÐµÐ´ÐµÑ‚Ð=B5 даннит=D0=
=B5 отново!

';
>> > footer();
>> > exit();
>> > }
>> >
>> > // Insert Query
>> > $sql =3D mysql_query("INSERT INTO carmade
>> > (car_descr)
>> > VALUES('{$_POST['car_descr']}')");
>> >
>> > // Insert query results
>> > if(!$sql){
>> > echo "Грешка при =
въвеждане на д=
анните:".mysql_error();
>> > } else {
>> >
>> > echo '

Маркат=
а "'.$_POST['car_descr'].
>> > '"е въведен=D0=
°
с номер:'.mysql_insert_id();
>> > echo '
/admin/carmade.php?req=3Dnew_carmade Ис=
кате ли да'.
>> > 'въведет=D0=
=B5 друга марка? ';
>> > }
>> > break;
>> >
>> > // Create car made form case
>> > case "new_carmade":
>> > myheader("Въвеждан=D 0=B5 =
на нова автомо=
билна марка");
>> > include $_SERVER['DOCUMENT_ROOT'].
>> > '/html/forms/carmade_insert.html';
>> > footer();
>> > break;
>> >
>> > default:
>> > myheader("Админист=D 1=80=
иране на списъ=
ка с автомобил=
ните марки");
>> > include $_SERVER['DOCUMENT_ROOT'].
>> > '/html/carmade_admin.html';
>> > footer();
>> > break;
>> >
>> > }
>> > ?>
>> >
>> > login.php:
>> > >> > include $_SERVER['DOCUMENT_ROOT'].
>> > '/layout.php';
>> >
>> >
>> > switch($_REQUEST['req']){
>> >
>> > case "validate":
>> >
>> > $validate =3D mysql_query("SELECT * FROM members
>> > WHERE username =3D '{$_POST['username']}'
>> > AND password =3D md5('{$_POST['password']}')=
"
>> > );
>> >
>> > $num_rows =3D mysql_num_rows($validate);
>> >
>> > if($num_rows == 1){
>> > while($row =3D mysql_fetch_assoc($validate)){
>> > $_SESSION['login'] =3D true;
>> > $_SESSION['userid'] =3D $row['member_id'];
>> > $_SESSION['first_name'] =3D $row['first_name'];
>> > $_SESSION['last_name'] =3D $row['last_name'];
>> > $_SESSION['email_address'] =3D $row['email_address'];
>> >
>> > if($row['admin_access'] == 1){
>> > $_SESSION['admin_access'] =3D true;
>> > }
>> > $login_time =3D mysql_query("UPDATE members
>> > SET last_login=3Dnow()
>> > WHERE id=3D'{$row['id']}'");
>> > }
>> > header("Location: /loggedin.php");
>> > } else {
>> > myheader("Входът в а=D0=
´Ð¼Ð¸Ð½Ð¸ÑÑ‚ратР¸Ð²Ð=BD=
ата зона е неус=
пешен!");
>> > echo '

Входът =
в страницата н=
е е успешен!

';
>> > echo '

Провер=D0=
µÑ‚Ð=B5 потребите=D0=
»ÑÐºÐ¾Ñ‚Ð=BE си '.
>> > 'име и парол=D0=
°Ñ‚а си и опитай=D1=
‚Ð=B5 пак или се '.
>> > 'обадете на =D0=
°Ð´Ð¼Ð¸Ð½Ð¸ÑÑ‚Ñ€Ð°Ñ ‚оÑ=80=
а.

';
>> > footer();
>> > }
>> > break;
>> >
>> > default:
>> > myheader("Вход!");
>> > include $_SERVER['DOCUMENT_ROOT'].
>> > '/html/forms/login_form.html';
>> > footer();
>> > break;
>> > }
>> > ?>
>> >
>> > database.php:
>> > >> > $link =3D mysql_pconnect('localhost','root','testing');
>> > $set =3D mysql_query('SET NAMES CP1251');
>> > $set =3D mysql_query('SET_COLLATION=3DCP1251_GENERAL_CI');
>> > mysql_select_db('samek_db', $link) or die(mysql_error());
>> >
>> > ?>
>> >
>> > common.php:
>> > >> >
>> > // Include Meta Content Class
>> > include $_SERVER['DOCUMENT_ROOT'].'/classes/clsMetaContent.php';
>> >
>> > // Include Email Class
>> > include $_SERVER['DOCUMENT_ROOT'].'/classes/clsEmail.php';
>> >
>> > // Include Database Connection File
>> > include $_SERVER['DOCUMENT_ROOT'].'/includes/database.php';
>> >
>> > // Include Session File
>> > include $_SERVER['DOCUMENT_ROOT'].'/includes/session.php';
>> >
>> > ?>
>> >
>> > Thank you for your help
>> >
>> >
>> > You're very welcome, I understand that you need a solution which allow=
s
>> you
>> > to keep using the connection this way.
>> >
>> > I doubt that your php.ini is the cause so I'll suggest the following:
>> >
>> > Try executing your MySQL queries by passing the $link variable to the
>> > function as the connection resource:
>> >
>> > mysql_query("SELECT...", $link);
>> >
>> > Something that also might cause it is that you use
>> (include|require)_once
>> > and that this module doesn't have access to the connection resource, i=
f
>> this
>> > is the case change it into include|require and see if that solves your
>> > issue. If not then could you please post some example code of your
>> module
>> if
>> > possible so we can be more helpful?
>> >
>> > Also be sure that you global $link; it in functions (I don't know if
>> this
>> > required since I didn't use it this way for a long while).
>> >
>> > Could you also please answer to the list instead of directly to me as
>> this
>> > might also be informative for others.
>> >
>> > --
>> > View this message in context:
>> http://www.nabble.com/PHP-MySQL-connection-for-particular-mo dule-tp17915=
108p17990192.html
>> > Sent from the Php - Database mailing list archive at Nabble.com.
>> >
>> >
>> > --
>> > PHP Database Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>
>=20
>=20
>=20
> --=20
> Isaak Malik
> Web Developer
>=20
>=20

--=20
View this message in context: http://www.nabble.com/PHP-MySQL-connection-fo=
r-particular-module-tp17915108p18005749.html
Sent from the Php - Database mailing list archive at Nabble.com.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-MySQL connection for particular module

am 19.06.2008 12:36:45 von isaak malik

------=_Part_4324_15293309.1213871805504
Content-Type: text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+ID4gVG8gdW5zdWJzY3JpYmUsIHZpc2l0OiBodHRwOi8vd3d3LnBocC5u ZXQvdW5zdWIucGhw
Cj4gPj4gPgo+ID4+ID4KPiA+Pgo+ID4KPiA+Cj4gPgo+ID4gLS0KPiA+IElz YWFrIE1hbGlrCj4g
PiBXZWIgRGV2ZWxvcGVyCj4gPgo+ID4KPgo+IC0tCj4gVmlldyB0aGlzIG1l c3NhZ2UgaW4gY29u
dGV4dDoKPiBodHRwOi8vd3d3Lm5hYmJsZS5jb20vUEhQLU15U1FMLWNvbm5l Y3Rpb24tZm9yLXBh
cnRpY3VsYXItbW9kdWxlLXRwMTc5MTUxMDhwMTgwMDU3NDkuaHRtbAo+IFNl bnQgZnJvbSB0aGUg
UGhwIC0gRGF0YWJhc2UgbWFpbGluZyBsaXN0IGFyY2hpdmUgYXQgTmFiYmxl LmNvbS4KPgo+Cj4g
LS0KPiBQSFAgRGF0YWJhc2UgTWFpbGluZyBMaXN0IChodHRwOi8vd3d3LnBo cC5uZXQvKQo+IFRv
IHVuc3Vic2NyaWJlLCB2aXNpdDogaHR0cDovL3d3dy5waHAubmV0L3Vuc3Vi LnBocAo+Cj4KCgot
LSAKSXNhYWsgTWFsaWsKV2ViIERldmVsb3Blcgo=
------=_Part_4324_15293309.1213871805504--

Re: PHP-MySQL connection for particular module

am 19.06.2008 12:38:02 von bateivan

Eric,

You gessed right. Both of the files are in my "docroot" directory.
I tried this. Unfortunely, it did not work ( perhaps, I did not use it
right), although, I followed your instructions.

Isaak gave me an idea which solved my problem (see his replies).

Thank you


Eric-275 wrote:
>
>
> ----------------------------------------------------
> http://myprojects.srhost.info
> eric{at}myprojects{dot}srhost{dot}info
> ----- Original Message -----
> From: "bateivan"
> To:
> Sent: Tuesday, June 17, 2008 11:19 PM
> Subject: [PHP-DB] PHP-MySQL connection for particular module
>
>
> :
> : Hello,
> :
> : First of all, please, have in mind that I am new in this business.
> :
> : I have a problem connecting with data base in one particular module.
> That's
> : right. The rest of the modules can connect to db, update tables with new
> : info but this one is refusing giving me message like this:
> :
> : "Warning: mysql_query() [function.mysql-query]: Access denied for user
> : 'ODBC'@'localhost' (using password: NO) in D:\Program Files\Apache
> Software
> : Foundation\Apache2.2\htdocs\login.php on line 17
> :
>
> This error message state that you have provided a wrong username and / or
> password
> use the die also to ensure the connection was created.
>
> : Warning: mysql_query() [function.mysql-query]: A link to the server
> could
> : not be established in
> : D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\login.php
> on
> : line 17"
> :
> :
> : It is a authentication module and this is the fragment of the code which
> is
> : giving me a hard time:
> :
> :
> ************************************************************ *******************
> : > : include $_SERVER['DOCUMENT_ROOT'].
> : '/layout.php';
> :
>
> Let's your included page on the same directory. Say f:\webroot\docroot
> As
> f:\webroot\docroot\layout.php
> f:\webroot\docroot\login.php
>
> then try change the line from
>
> include $_SERVER['DOCUMENT_ROOT'].
> '/layout.php';
>
> to
>
> $app_root = './';
> include ($app_root . 'layout.php');
>
>
> : switch($_REQUEST['req']){
> :
> : case "validate":
> :
> : $validate = mysql_query("SELECT * FROM members
> : WHERE username = '{$_POST['username']}'
> : AND password = md5('{$_POST['password']}')"
> : );
> :
> : etc....
> :
> :
> ************************************************************ *******************
> :
> : My platform is WinXP on drive F:\ (I have Win'98 on C:\) and as you can
> see
> : my program files are on D:\. All this may not be important but I listed
> : anyway.
> : It is installed Apache 2.2.6 using windows installer, PHP 5.2.6 (I just
> : replaced 5.2.5 hoping to fix the problem), and MySQL 5.0.45.
> :
> : I am using persisten connection which should be on until you restart the
> : server. I have a file included in every page for connection with MySQL
> and
> : data base.
> : PHP manual says that "mysql_query" reuses the existing connection or try
> to
> : create one if not present (I think, according to the warning is trying
> to
> : create one).
> : I had been checking after each step using phpinfo() if the connection is
> : there and it's there but for some reason the above fragment does not
> work.
> : As I mentioned above the rest of my modules are working fine with mysql.
> :
> : I checked the "php.ini" file. I compared it to "php.ini.recomended" from
> the
> : .zip distribusion package and they are almost identical exept couple of
> : things for error reporting.
> : I, also checked FAQ, mail listings and other forums but it does not seem
> : anybody had a similar problem.
> :
> : In one of my tests I included a line for connection just before the
> problem
> : lines, as described below, and it worked but my intention is to keep
> such
> : lines in a separate files and include them in every page instead.
> :
> :
> ************************************************************ *******************
> : .......
> :
> : $link = mysql_pconnect('localhost', 'root', 'testing');
> :
> :
> : $validate = mysql_query("SELECT * FROM members
> : WHERE username = '{$_POST['username']}'
> : AND password = md5('{$_POST['password']}')"
> : );
> : etc.
> :
> ************************************************************ *******************
> :
> : As I metioned, this is an authentication module and, may be, that's why
> is
> : behaving diferently from the rest or I need to do some setup changes in
> : "php.ini" which I am not familiar with.
> :
> : If anyone has had simmilar problem I would appreciate his/her input.
> Please,
> : help me resolve this mistery.
> :
> : --
> : View this message in context:
> http://www.nabble.com/PHP-MySQL-connection-for-particular-mo dule-tp17915108p17915108.html
> : Sent from the Php - Database mailing list archive at Nabble.com.
> :
> :
> : --
> : PHP Database Mailing List (http://www.php.net/)
> : To unsubscribe, visit: http://www.php.net/unsub.php
> :
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

--
View this message in context: http://www.nabble.com/PHP-MySQL-connection-for-particular-mo dule-tp17915108p18005755.html
Sent from the Php - Database mailing list archive at Nabble.com.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-MySQL connection for particular module

am 20.06.2008 01:57:14 von dmagick

> [new code]
> if (!mysql_connect($a, $b, $c)) return;
>
> if (!mysql_select_db($dbname)) return;
>
> $res = mysql_query("SELECT * FROM manual;", $link);
> [/new code]


Isn't going to work because $link is not defined and definitely not a
resource like mysql_query expects.

> OR, optionally, to surpress the warnings:
>
> [new code]
> if (!mysql_connect($a, $b, $c)) return;
>
> $link = null;
>
> if (!mysql_select_db($dbname)) return;
>
> $res = mysql_query("SELECT * FROM manual;", $link);
> [/new code]

Isn't going to work because mysql_query needs a resource to connect to.
You've defined $link as null.

$ cat test.php
$user = 'my_db_user';
$pass = 'my_pass';
$host = 'localhost';
$db = 'my_db';

error_reporting(E_ALL);
ini_set('display_errors', true);

if (!mysql_connect($host, $user, $pass)) {
die("unable to connect");
}

if (!mysql_select_db($db)) {
die("unable to choose db");
}

$link = null;
$res = mysql_query('select version() as version', $link);
while ($row = mysql_fetch_assoc($res)) {
print_r($row);
}


$ php test.php

Warning: mysql_query(): supplied argument is not a valid MySQL-Link
resource in /path/to/test.php on line 19

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL
result resource in /path/to/test.php on line 20


--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-MySQL connection for particular module

am 20.06.2008 10:12:07 von Evert Lammerts

I should've checked the assumption.

A little strange though for a scripting language. I'd say, since
default behaviour of mysql_* functions is to assume the last opened
link when a parameter is not passed, and since default behaviour is to
evaluate null, false and 0 the same, mysql_* functions should issue a
warning when a not valid link is passed but still use the last opened
link (in that logic, null should also generate a warning though). I'm
guessing the reason is that mysql_connect returns false when it fails,
but i can't see a reason why an undefined variable cannot be used.

All that and I don't remember what it was for.

On Fri, Jun 20, 2008 at 1:57 AM, Chris wrote:
>
>> [new code]
>> if (!mysql_connect($a, $b, $c)) return;
>>
>> if (!mysql_select_db($dbname)) return;
>>
>> $res = mysql_query("SELECT * FROM manual;", $link);
>> [/new code]
>
>
> Isn't going to work because $link is not defined and definitely not a
> resource like mysql_query expects.
>
>> OR, optionally, to surpress the warnings:
>>
>> [new code]
>> if (!mysql_connect($a, $b, $c)) return;
>>
>> $link = null;
>>
>> if (!mysql_select_db($dbname)) return;
>>
>> $res = mysql_query("SELECT * FROM manual;", $link);
>> [/new code]
>
> Isn't going to work because mysql_query needs a resource to connect to.
> You've defined $link as null.
>
> $ cat test.php
> > $user = 'my_db_user';
> $pass = 'my_pass';
> $host = 'localhost';
> $db = 'my_db';
>
> error_reporting(E_ALL);
> ini_set('display_errors', true);
>
> if (!mysql_connect($host, $user, $pass)) {
> die("unable to connect");
> }
>
> if (!mysql_select_db($db)) {
> die("unable to choose db");
> }
>
> $link = null;
> $res = mysql_query('select version() as version', $link);
> while ($row = mysql_fetch_assoc($res)) {
> print_r($row);
> }
>
>
> $ php test.php
>
> Warning: mysql_query(): supplied argument is not a valid MySQL-Link
> resource in /path/to/test.php on line 19
>
> Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL
> result resource in /path/to/test.php on line 20
>
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php