Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #8163 > unrolled thread

about php connection string

Started byamitjaluf@gmail.com
First post2013-01-31 23:47 -0800
Last post2013-02-03 19:41 -0800
Articles 6 — 5 participants

Back to article view | Back to comp.lang.php


Contents

  about php connection string amitjaluf@gmail.com - 2013-01-31 23:47 -0800
    Re: about php connection string Kim André Akerø <kimandre@nospambetadome.com> - 2013-02-01 12:12 +0100
      Re: about php connection string The Natural Philosopher <tnp@invalid.invalid> - 2013-02-01 11:29 +0000
        Re: about php connection string Jerry Stuckle <jstucklex@attglobal.net> - 2013-02-01 08:46 -0500
        Re: about php connection string "Peter H. Coffin" <hellsop@ninehells.com> - 2013-02-01 08:55 -0600
      Re: about php connection string amitjaluf@gmail.com - 2013-02-03 19:41 -0800

#8163 — about php connection string

Fromamitjaluf@gmail.com
Date2013-01-31 23:47 -0800
Subjectabout php connection string
Message-ID<839bd343-9011-4c1d-952f-760377d5a2dd@googlegroups.com>
Hello All
i am writing a connection string to connect database to the web page but when i run this with Firefox it shows Nothing. I am using Linux(Debian) on machine.

here is the code can anyone help me where i am wrong.

<?php
     $db=mysql_connect("localhost","xyz","");
     mysql_select_db("mysql",$db);
     $rs=mysql_query("select * from emp",$db);
     printf("User: %s\n",mysql_result($rs,0,"Ename")); 
?>

and the other thing is when i save the .php file in "/var/www" its show me message Permission denied so where i have to put these files(Project) where from i can run.

[toc] | [next] | [standalone]


#8164

FromKim André Akerø <kimandre@nospambetadome.com>
Date2013-02-01 12:12 +0100
Message-ID<op.wrtqrxz1ptrp3x@neonk2.intrahouse.local>
In reply to#8163
På Fri, 01 Feb 2013 08:47:36 +0100, skrev <amitjaluf@gmail.com>:

> Hello All
> i am writing a connection string to connect database to the web page but  
> when i run this with Firefox it shows Nothing. I am using Linux(Debian)  
> on machine.
>
> here is the code can anyone help me where i am wrong.
>
> <?php
>      $db=mysql_connect("localhost","xyz","");
>      mysql_select_db("mysql",$db);
>      $rs=mysql_query("select * from emp",$db);
>      printf("User: %s\n",mysql_result($rs,0,"Ename"));
> ?>

First, what do you see if you view the page source in Firefox? Do you see  
your original PHP code, or is it just blank? If you see PHP code, it would  
mean that your server (Apache, nginx, etc) is not configured to process  
PHP code.

Second, does the database user you use to connect with actually have  
access to the database you're selecting?

If you don't see PHP code in your page source, you might have errors in  
your query or database connection. To see the errors, I suggest you  
temporarily enable error reporting to see any hidden error messages. You  
can do this in runtime by putting these two lines at the top of your first  
<?php code block:

ini_set('display_errors', 'stdout'); // if you're using PHP older than  
5.2.4, use '1' instead of 'stdout'
error_reporting(E_ALL);

Since there aren't any syntax errors in the script you pasted above, this  
should output all error messages (even notices) to your HTML document.

> and the other thing is when i save the .php file in "/var/www" its show  
> me message Permission denied so where i have to put these files(Project)  
> where from i can run.

Make sure the .php file is readable by all users ("chmod a+r filename.php"  
 from the command line, or right-click - File Permissions in FileZilla).  
Also, it may be that the /var/www directory has been set to not be allowed  
in the webserver configuration (if this is the case, though, even not  
specifying a file name in the URL would give the "Permission denied").

-- 
Kim André Akerø
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)

[toc] | [prev] | [next] | [standalone]


#8165

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2013-02-01 11:29 +0000
Message-ID<keg8uq$ohd$1@news.albasani.net>
In reply to#8164
On 01/02/13 11:12, Kim André Akerø wrote:
> På Fri, 01 Feb 2013 08:47:36 +0100, skrev <amitjaluf@gmail.com>:
>
>> Hello All
>> i am writing a connection string to connect database to the web page
>> but when i run this with Firefox it shows Nothing. I am using
>> Linux(Debian) on machine.
>>
>> here is the code can anyone help me where i am wrong.
>>
>> <?php
>>      $db=mysql_connect("localhost","xyz","");
>>      mysql_select_db("mysql",$db);
>>      $rs=mysql_query("select * from emp",$db);
>>      printf("User: %s\n",mysql_result($rs,0,"Ename"));
>> ?>
>
> First, what do you see if you view the page source in Firefox? Do you
> see your original PHP code, or is it just blank? If you see PHP code, it
> would mean that your server (Apache, nginx, etc) is not configured to
> process PHP code.
>
> Second, does the database user you use to connect with actually have
> access to the database you're selecting?
>
> If you don't see PHP code in your page source, you might have errors in
> your query or database connection. To see the errors, I suggest you
> temporarily enable error reporting to see any hidden error messages. You
> can do this in runtime by putting these two lines at the top of your
> first <?php code block:

I found that later versions of mysql tend to default to NOT allowing 
'localhost' but will accept '127.0.0.1'

>
> ini_set('display_errors', 'stdout'); // if you're using PHP older than
> 5.2.4, use '1' instead of 'stdout'
> error_reporting(E_ALL);
>
Or look in /var/log/apache2/error.log

> Since there aren't any syntax errors in the script you pasted above,
> this should output all error messages (even notices) to your HTML document.
>
>> and the other thing is when i save the .php file in "/var/www" its
>> show me message Permission denied so where i have to put these
>> files(Project) where from i can run.
>
> Make sure the .php file is readable by all users ("chmod a+r
> filename.php" from the command line, or right-click - File Permissions
> in FileZilla). Also, it may be that the /var/www directory has been set
> to not be allowed in the webserver configuration (if this is the case,
> though, even not specifying a file name in the URL would give the
> "Permission denied").
>

in general the apache server needs  read permission.

I generally fix that by working out what group apache is in, and 
sertting sticky bits on group attributes in /var/www  directories, so 
all files belonging to the www-data group. Unless the file doesn't have 
GROUP read perms, which is rare, that means apache can read it.

-- 
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to 
lead are elected by the least capable of producing, and where the 
members of society least likely to sustain themselves or succeed, are 
rewarded with goods and services paid for by the confiscated wealth of a 
diminishing number of producers.

[toc] | [prev] | [next] | [standalone]


#8167

FromJerry Stuckle <jstucklex@attglobal.net>
Date2013-02-01 08:46 -0500
Message-ID<kegh09$n50$1@dont-email.me>
In reply to#8165
On 2/1/2013 6:29 AM, The Natural Philosopher wrote:
> On 01/02/13 11:12, Kim André Akerø wrote:
>> På Fri, 01 Feb 2013 08:47:36 +0100, skrev <amitjaluf@gmail.com>:
>>
>>> Hello All
>>> i am writing a connection string to connect database to the web page
>>> but when i run this with Firefox it shows Nothing. I am using
>>> Linux(Debian) on machine.
>>>
>>> here is the code can anyone help me where i am wrong.
>>>
>>> <?php
>>>      $db=mysql_connect("localhost","xyz","");
>>>      mysql_select_db("mysql",$db);
>>>      $rs=mysql_query("select * from emp",$db);
>>>      printf("User: %s\n",mysql_result($rs,0,"Ename"));
>>> ?>
>>
>> First, what do you see if you view the page source in Firefox? Do you
>> see your original PHP code, or is it just blank? If you see PHP code, it
>> would mean that your server (Apache, nginx, etc) is not configured to
>> process PHP code.
>>
>> Second, does the database user you use to connect with actually have
>> access to the database you're selecting?
>>
>> If you don't see PHP code in your page source, you might have errors in
>> your query or database connection. To see the errors, I suggest you
>> temporarily enable error reporting to see any hidden error messages. You
>> can do this in runtime by putting these two lines at the top of your
>> first <?php code block:
>
> I found that later versions of mysql tend to default to NOT allowing
> 'localhost' but will accept '127.0.0.1'
>

Then you screwed up your configuration (I'm not surprised).  'localhost' 
is valid in all versions of MySQL.

>>
>> ini_set('display_errors', 'stdout'); // if you're using PHP older than
>> 5.2.4, use '1' instead of 'stdout'
>> error_reporting(E_ALL);
>>
> Or look in /var/log/apache2/error.log
>

Which is only valid if errors are being logged.

>> Since there aren't any syntax errors in the script you pasted above,
>> this should output all error messages (even notices) to your HTML
>> document.
>>
>>> and the other thing is when i save the .php file in "/var/www" its
>>> show me message Permission denied so where i have to put these
>>> files(Project) where from i can run.
>>
>> Make sure the .php file is readable by all users ("chmod a+r
>> filename.php" from the command line, or right-click - File Permissions
>> in FileZilla). Also, it may be that the /var/www directory has been set
>> to not be allowed in the webserver configuration (if this is the case,
>> though, even not specifying a file name in the URL would give the
>> "Permission denied").
>>
>
> in general the apache server needs  read permission.
>
> I generally fix that by working out what group apache is in, and
> sertting sticky bits on group attributes in /var/www  directories, so
> all files belonging to the www-data group. Unless the file doesn't have
> GROUP read perms, which is rare, that means apache can read it.
>


-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#8169

From"Peter H. Coffin" <hellsop@ninehells.com>
Date2013-02-01 08:55 -0600
Message-ID<slrnkgnlri.m9f.hellsop@nibelheim.ninehells.com>
In reply to#8165
On Fri, 01 Feb 2013 11:29:30 +0000, The Natural Philosopher wrote:
> On 01/02/13 11:12, Kim Andr?? Aker?? wrote:
>> P?? Fri, 01 Feb 2013 08:47:36 +0100, skrev <amitjaluf@gmail.com>:
>>
>>> Hello All
>>> i am writing a connection string to connect database to the web page
>>> but when i run this with Firefox it shows Nothing. I am using
>>> Linux(Debian) on machine.
>>>
>>> here is the code can anyone help me where i am wrong.
>>>
>>> <?php
>>>      $db=mysql_connect("localhost","xyz","");
>>>      mysql_select_db("mysql",$db);
>>>      $rs=mysql_query("select * from emp",$db);
>>>      printf("User: %s\n",mysql_result($rs,0,"Ename"));
>>> ?>
>>
>> First, what do you see if you view the page source in Firefox? Do you
>> see your original PHP code, or is it just blank? If you see PHP code, it
>> would mean that your server (Apache, nginx, etc) is not configured to
>> process PHP code.
>>
>> Second, does the database user you use to connect with actually have
>> access to the database you're selecting?
>>
>> If you don't see PHP code in your page source, you might have errors in
>> your query or database connection. To see the errors, I suggest you
>> temporarily enable error reporting to see any hidden error messages. You
>> can do this in runtime by putting these two lines at the top of your
>> first <?php code block:
>
> I found that later versions of mysql tend to default to NOT allowing 
> 'localhost' but will accept '127.0.0.1'

#1 newbie trap. "localhost" is NOT A NETWORK CONNECTION to mysql.
"localhost" is a OS socket or named pipe connection, depending on OS.

-- 
Cunningham's First Law:
Any sufficiently complex deterministic system will exhibit
non-deterministic behaviour.

[toc] | [prev] | [next] | [standalone]


#8225

Fromamitjaluf@gmail.com
Date2013-02-03 19:41 -0800
Message-ID<e3521071-8bf0-4fe0-8e4c-0514f0439c04@googlegroups.com>
In reply to#8164
Thanks Kim for the advice
the error handling work's here 
it shows the error in the particular line


[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web