Re: PHP-MySQL connection for particular module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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, <ivanovivans@xxxxxxxx> 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 <ivanovivans@xxxxxxxx> 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:
> >>
> >>
> >>
> *******************************************************************************
> >> <?php
> >> 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-module-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-module-tp17915108p17916593.html
>
>
-- 
Isaak Malik
Web Developer

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux