php-general Digest 4 Jul 2008 20:53:49 -0000 Issue 5550

Topics (messages 276279 through 276288):

No Database Connection possible (mySQL)
        276279 by: Aviation Coding
        276283 by: David Robley
        276287 by: M. Sokolewicz

Re: [SPAM] [PHP] No Database Connection possible (mySQL)
        276280 by: Chris Scott
        276281 by: Chris Haensel

Re: Installed 5.2.6 but phpinfo() still says 5.0.2
        276282 by: David Robley

Convert PDF Files to PCL-Files
        276284 by: jogisarge

Creating XML files
        276285 by: It flance

Hi,
        276286 by: John Jairo Vega Angulo
        276288 by: Shawn McKenzie

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Hi all,

I am having problems with a connection to a mysql database.

I am using

----
function con()
{
mysql_connect("localhost","user","pass") or die(mysql_error());
mysql_select_db("tava") or die(mysql_error());
}
----

Now, when I call the _function_ (!)
----
con() or die("no con");
----
I get the "no con" output.

When I call the mysql_connect and mysql_select directly before executing a
query, I get some DB output. But that won't work when I am using the
function...

Any ideas would be greatly appreciated.

Cheers!

Chris

--- End Message ---
--- Begin Message ---
Aviation Coding wrote:

> Hi all,
> 
> I am having problems with a connection to a mysql database.
> 
> I am using
> 
> ----
> function con()
> {
> mysql_connect("localhost","user","pass") or die(mysql_error());
> mysql_select_db("tava") or die(mysql_error());
> }
> ----
> 
> Now, when I call the _function_ (!)
> ----
> con() or die("no con");
> ----
> I get the "no con" output.
> 
> When I call the mysql_connect and mysql_select directly before executing a
> query, I get some DB output. But that won't work when I am using the
> function...
> 
> Any ideas would be greatly appreciated.
> 
> Cheers!
> 
> Chris

I think you need to return something from the function, like true if the
connection/select worked, false if not.



Cheers
-- 
David Robley

If I were two faced, would I wear this one?
Today is Setting Orange, the 39th day of Confusion in the YOLD 3174. 


--- End Message ---
--- Begin Message ---
David Robley wrote:
Aviation Coding wrote:

Hi all,

I am having problems with a connection to a mysql database.

I am using

----
function con()
{
mysql_connect("localhost","user","pass") or die(mysql_error());
mysql_select_db("tava") or die(mysql_error());
}
----

Now, when I call the _function_ (!)
----
con() or die("no con");
----
I get the "no con" output.

When I call the mysql_connect and mysql_select directly before executing a
query, I get some DB output. But that won't work when I am using the
function...

Any ideas would be greatly appreciated.

Cheers!

Chris

I think you need to return something from the function, like true if the
connection/select worked, false if not.



Cheers
You are correct.

function foo() {
 // does something
}

var_dump(foo()); // returns NULL

why? because you don't explicitly return anything. If you did, that'd be the return value. So if you did:
function bar() {
   // does something
   return true;
}

var_dump(bar()); // return true

Now, your script assumes a return-value:
baz() or somethingElse();
is an expression. This basically says:
if(!baz()) {
   somethingElse();
}

Now, return (implicitly) null will result in (trough lazy comparison) a false value (*null == false*, null !== false), which then triggers your die() condition. Returning a meaningful value will get rid of that.

Other than that, choose 1 of 2 techniques:
1. error out inside the function itself (like you do now)
OR
2. error out based on the return-value of the function (like you do now ASWELL)
don't combine 1 and 2, stick with either, but not both.

function con()
{
mysql_connect("localhost","user","pass") or die(mysql_error());
mysql_select_db("tava") or die(mysql_error());
}
con();

works. The following would work too:
function con()
{
$r = mysql_connect("localhost","user","pass");
if(!$r) {
   return false;
}
$r2 = mysql_select_db("tava");
if(!$r2) {
   return false;
}
return true;
}

con() or die('no conn');

would also work correctly. So, stick with either, don't mix em.

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Aviation Coding [mailto:[EMAIL PROTECTED]
> Sent: Friday, July 04, 2008 10:15 AM
> To: [EMAIL PROTECTED]
> Subject: [SPAM] [PHP] No Database Connection possible (mySQL)
> Importance: Low
> 
> Hi all,
> 
> I am having problems with a connection to a mysql database.
> 
> I am using
> 
> ----
> function con()
> {
> mysql_connect("localhost","user","pass") or die(mysql_error());
> mysql_select_db("tava") or die(mysql_error());
> }
> ----
> 
> Now, when I call the _function_ (!)
> ----
> con() or die("no con");
> ----
> I get the "no con" output.
> 
> When I call the mysql_connect and mysql_select directly before
executing a
> query, I get some DB output. But that won't work when I am using the
> function...
> 
> Any ideas would be greatly appreciated.
> 
> Cheers!
> 
> Chris

It's a bit of a long shot but are you using variables in the function
which might be out of scope?

--- End Message ---
--- Begin Message ---
 

-----Original Message-----
From: Chris Scott [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 04, 2008 11:41 AM
To: [EMAIL PROTECTED]
Subject: [PHP] FW: [SPAM] [PHP] No Database Connection possible (mySQL)
Importance: Low

> -----Original Message-----
> From: Aviation Coding [mailto:[EMAIL PROTECTED]
> Sent: Friday, July 04, 2008 10:15 AM
> To: [EMAIL PROTECTED]
> Subject: [SPAM] [PHP] No Database Connection possible (mySQL)
> Importance: Low
> 
> Hi all,
> 
> I am having problems with a connection to a mysql database.
> 
> I am using
> 
> ----
> function con()
> {
> mysql_connect("localhost","user","pass") or die(mysql_error());
> mysql_select_db("tava") or die(mysql_error());
> }
> ----
> 
> Now, when I call the _function_ (!)
> ----
> con() or die("no con");
> ----
> I get the "no con" output.
> 
> When I call the mysql_connect and mysql_select directly before
executing a
> query, I get some DB output. But that won't work when I am using the
> function...
> 
> Any ideas would be greatly appreciated.
> 
> Cheers!
> 
> Chris

It's a bit of a long shot but are you using variables in the function
which might be out of scope?

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

Hi mate,

no, I am using no variables in the other function. The function goes like

con() or die("no con");
$query = "SELECT ********";
and so on

and I always get "no con"...

Cheers!


Chris


--- End Message ---
--- Begin Message ---
x0ml wrote:

> For some reason this first post didn't "post" to this newsgroup...
> 
> 
> "x0ml" <[EMAIL PROTECTED]> wrote in message news:...
>> I've installed PHP version 5.2.6 but phpinfo() and php -v both report
>> back
>> the old version 5.0.2.  I even copied php.ini-dist from the distribution
>> to /etc/php.ini and restarted the physical server.  It still does show
>> version 5.2.6 as the current version.
>>
>> As a sidenote, I'm having the same thing occur with my Apache upgrade
>> that
>> I just did too.  It still thinks its version 2.0.54 instead of version
>> 2.0.63. I tweaked my httpd.conf file, didn't make any difference.
>>
>> I'm running Fedora 2.6.11-1.1369_FC4.  Any ideas where to look?
>>
>> Mark
>>
>>
You did restart the server after making the changes?



Cheers
-- 
David Robley

Push the limit, and the limit will move away!
Today is Setting Orange, the 39th day of Confusion in the YOLD 3174. 


--- End Message ---
--- Begin Message ---
Hello @all,

i am running php5 on a IBM i5 V5R4.
now i have to print exisiting pdf-files.

the problem is, i cant use external programms like pdftops or other stuff
like this, because the php core runs in the pase environment.

is there any possibility to convert existing pdfs to pcl files ?

bye jo




-- 
View this message in context: 
http://www.nabble.com/Convert-PDF-Files-to-PCL-Files-tp18280322p18280322.html
Sent from the PHP - General mailing list archive at Nabble.com.


--- End Message ---
--- Begin Message ---
Hi all,

Some months ago i worked with XML. And i remember that i was able to create xml 
files quite easily. Now i don`t have the book i used by the time. I made many 
searches in google and i don't find something interesting. So i'm wondering if 
somebody can give a good link with examples. If i remeber well, i can create 
axml file without writing the hole file to a string before writing the string 
to the file.

Thanks a lot


      


--- End Message ---
--- Begin Message ---
Hi,
  How are u doing these days?Yesterday I found a web of a large trading
company from china,which is an agent of all the well-known digital product
factories,and facing to both wholesalers,retailsalers,and personal customer
all over the world. They export all kinds of digital products and offer most
competitive and reasonable price and high quality goods for our clients,so i
think we you make a big profit if we do business with them.And they promise
they will provide the best after-sales-service.In my opinion we can make a
trial order to test that. Look forward to your early reply!
             The Web address:http://www.mwhdy.com/

--- End Message ---
--- Begin Message ---
John Jairo Vega Angulo wrote:
Hi,
  How are u doing these days?Yesterday I found a web of a large trading
company from china,which is an agent of all the well-known digital product
factories,and facing to both wholesalers,retailsalers,and personal customer
all over the world. They export all kinds of digital products and offer most
competitive and reasonable price and high quality goods for our clients,so i
think we you make a big profit if we do business with them.And they promise
they will provide the best after-sales-service.In my opinion we can make a
trial order to test that. Look forward to your early reply!
             The Web address:http://www.mwhdy.com/

Hi John Jairo Vega Angulo,

I'm doing well. Wow! That's truly awesome! I'm all about promises, let's do a trial order!

Happy Independence Day!
-Shawn

--- End Message ---

Reply via email to