0

I am new to coding in php and also getting the environment set up on my local computer.

Here's the current setup configuration - I have installed wamp server version 2.2 which has the following - Apache 2.4.2, php 5.4.3, mysql 5.5.24

There is a very simple php code that i had written -

<?
mysql_connect("localhost","user","password");
mysql_select_db("mydbase");
$result = mysql_query("SELECT * FROM names WHERE ID LIKE '2'"); 
   while($r=mysql_fetch_array($result))
{
$id = $r["id"];
$name = $r["name"];

}//close while
?>

Even a simple echo is not working. the output is blank. the same code works on the web server. It has the same user name, password and the tables were exported (from the webserver) and imported (into the local mysql).

The phpinfo() page shows the following -

display_errors - on - on error_log - no value - no value

The php.ini file shows the following - ; display_errors ; Default Value: On ; Development Value: On ; Production Value: Off and

;error_log = php_errors.log
; Log errors to syslog (Event Log on NT, not valid in Windows 95).
;error_log = syslog
error_log = c:/wamp/logs/php_error.log

The error logs are empty.

When i look at the source in the browser, for the page online - it shows the output for the page on the local computer - it just shows the php code

Could anyone please let me know what the problem could be? It seems like that there are some settings that i have messed up. But, i did not change anything - it is a regular installation and no custom settings were added.

11
  • Has the file the .php as extension? Commented Aug 7, 2012 at 13:40
  • What does <php phpinfo(); ?> show you? Commented Aug 7, 2012 at 13:40
  • Make sure that the server (I assume apache) is set up to handle php requests. It should be handling php extensions with application/x-httpd-php (and mod_php should be enabled unless you are using FastCGI or something) Commented Aug 7, 2012 at 13:41
  • Does the MySQL user/password form the webserver also exist on your local server? Commented Aug 7, 2012 at 13:41
  • @MikeBrant "It has the same user name, password and the tables were exported (from the webserver) and imported (into the local mysql)" Commented Aug 7, 2012 at 13:42

3 Answers 3

1

Your script doesn't work, but your phpinfo page works? Check short_open_tag in your php.ini. Or modify your script and change your opening <? to <?php. If that works, you found the problem!

Sign up to request clarification or add additional context in comments.

3 Comments

the short_open_tag is set to off (on both local and master value)
Glad to hear it helped, but to please refer from not using short opening tags. That's not good practice.
@DainisAbols, oh, okay.. didnt know that. was just experimenting with a code i found.. will use the standard codes now.. (which i am assuming, would be using <?php > instead of <? > )
0

this happened to me too, try enabling the mime_module of apache

1 Comment

the mime_module is enabled (there is a tick next to it in Apache Modules in the WAMP configuration)
0

If, on info.php file creation with

<?php phpinfo(); ?>

You actully get that result, check if your webserver is configured to use php as script files:

Check inside httpd.conf for these lines and alter them if necessary:

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

Restart server and try to run the script again.

2 Comments

Or try installing an older wamp version and carefully click on all php options when installing it. That might be easier for you.
i checked the httpd.conf and it shows the following <IfModule dir_module> DirectoryIndex index.php index.php3 index.html index.htm </IfModule>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.