FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » about php connection string
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: about php connection string [message #180230 is a reply to message #180229] Fri, 01 February 2013 11:12 Go to previous messageGo to previous message
Kim Andr Aker is currently offline  Kim Andr Aker
Messages: 17
Registered: September 2010
Karma:
Junior Member
På Fri, 01 Feb 2013 08:47:36 +0100, skrev <amitjaluf(at)gmail(dot)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(at)NOSPAMbetadome(dot)com
(remove NOSPAM to contact me directly)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to get data for website pages..
Next Topic: Hot list for BA/QA, BA – Insurance, Embedded Engineer & Technical BM
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Sep 19 01:35:26 GMT 2024

Total time taken to generate the page: 0.03495 seconds