|
Posted by Shelly on 08/17/07 16:14
"Rik" <luiheidsgoeroe@hotmail.com> wrote in message
news:op.tw7mbyxuqnv3q9@metallium...
On Fri, 17 Aug 2007 17:13:19 +0200, Shelly
<sheldonlg.news@asap-consult.com> wrote:
> Here is a crazy question that has happend to me once before.
>
> I have an include file for the connection information to the server. It
> is
> like this:
>
> $hostname= "the_server_location";
> $database = "the_database_name";
> $dbUsername = "the_username";
> $dbPassword = "the_password";
> $dbCon = mysql_pconnect($hostname, $dbUsername, $dbPassword) or
> die(mysql_error());
Are you very sure you need mysql_pconnect()? If you do not know exactly
what it does are you are unsure, you clearly need mysql_connect().
===> Yes, I can use mysql_connect. I don't need a persistent connection.
> mysql_select_db($database, $dbCon);
>
> In my main file I have right near the top:
>
> require_once("dbLogin.php");
>
> I then have lines in a function where I pass in $sbCon as $con (The
> quotes
> are single-double for the fist one and double-single-double for the
> second
> one):
>
> $q = "SELECT * FROM Company WHERE accountNumber='" . $num . "'";
> $res = mysql_query($q, $con) or die(mysql_error());
$con <> $dbCon
====> My typo threw you off. I pass in $dbCon as $con, so I use $con.
When the code is inline it works. It doesn't when I have the require_once.
$res = mysql_query($q, $dbCon) or die(mysql_error());
> This gives me an invalid resource at the mysql_query line.
>
> HOWEVER, If I comment out the require_once line and copy and paste the
> code
> for it directly into the calling module, it works fine. Note that this
> was
> a strict cut and paste and the only keyboard strokes that I did were the
> the
> slashes to comment out the require_once.
Hmmmz, I think the fault is elsewhere.
===> No, the ONLY change between working and non-working versions is that I
paste the lines on code in for the working version and use a require_once in
the non-working version.
--
Rik Wasmus
Navigation:
[Reply to this message]
|