php on windows server - php

I am trying to create my first dynamic site on windows server 2008 r2. I have created other dynamic sites successfully on linux based systems but I am having a little bit of trouble with this.
So i have php, mysql and phpmyadmin installed on the server.
I have a page (index.php) with the following:
<?php
include 'php/index.php';
mysql_set_charset('utf8');
?>
This works fine and does not show when i do 'view source' on the displayed page in a web browser.
Further down my page i have the following:
<?=$obj->get_email()?>
This statement is to be used to pull information from a database. When i do view source it shows the get_email() command as seen above. Instead of what it should be replaced with .
Is this a PHP issue? Is this type of command not suitable with windows server or am i just doing something completely stupid??

Try it without short tags:
<?php echo $obj->get_email(); ?>

You should check php.ini for the setting: short_open_tag and change it to 1 if you wish to be able to use <? to jump into PHP mode.
Barring that, just changing it to <?php echo $obj->get_email(); ?> will fix your problem.
Reference

Related

XAMPP PHP is not working

I have just installed XAMPP again, I was using IIS but I have now disabled that.
For some reason disabling it didn't seem to work, as the ports still clashed, so instead I have changed the port for Apache to "1234".
As you can see from the control panel below XAMPP seems to be running just fine, the index page shows up fine at least.
I made a quick test page and placed it in my install directory (C:\xampp\htdocs\testing.php)
<?
$test = "hello world";
echo $test;
?>
I then load this location in Chrome: http://localhost:1234/testing.php
But for some reason the page is blank, when I view the pages source I see this:
<?
$test = "hello world";
echo $test;
?>
Any ideas?
Edit:
Fixed thanks, I was an idiot and didn't open it with
Instead of wasting this thread for such a stupid mistake here is another question.
Is there a version of Chrome or Firefox I can use to run my website but lock it in full screen and require a password to get out of it?
Try to use <?php tag instead of <?, this is often disabled in standard php installations.
BTW, to activate short tags, the property is
short_open_tag=On
in your php.ini.

PHP code being displayed, not interpreted

I recently set up an AWS EC2 instance and installed Apache, PHP, and MySQL on the 64-bit Linux server using yum
Then I uploaded my php files for my contact form in /var/HTML/WWW
It displays fine except parts of my contact form are being displayed. They are PHP— the PHP tags and the code within them are being shown.
Here is a live example: 23.23.152.36
And here is a version on another server where its working fine.
Does anyone have any ideas why this is happening?
Do you have PHP enabled on your webserver? For Apache, you may need to modify httpd.conf to enable PHP.
Can you run phpmyinfo() on your webserver?
Enable short_open_tag in you php.ini
short_open_tag
Default Value: On
Development Value: Off
Production Value: Off
shorthand notation is on its way to deprication, i wouldnt suggest building code with shorthand notation anymore.
just use <?php echo ?>
You want to change <?php=$name;?> to <?= $name ?>. That's what you need to do if you want to use the shorthand notation.

I didnt get the desired result with wampserver in the <? syntax.Why?

I am using wamp server 2.0 on windows XP with PHP version 5.2.5 when I am using the following code
<?
echo "hai";
?>
I am not getting the output. But when I am using
<?php
echo "hai";
?>
Got the result.If I am using the first one in Linux server I got the output.One of my large project like the first one in all php pages.I want to configure with wamp.SO if first coding needs to work what can I do?
My first guess is your php.ini isn't configured for this. The parameter short_open_tag is responsible for it.
Edit your php.ini, search the following parameter and activate it (or add it when its missing there):
short_open_tag = On
More details are in the php-manual.
i'm not using wamp now, maybe you can test solution from http://www.wampserver.com/phorum/read.php?2,50473,50474#msg-50474.
Wish this can help you. :)

Using PHP on non-supportive server

I have a rather complicated scenario that I have never really had to deal with before. I am creating a website that will be hosted on a web-server without PHP support. But I need to call a PHP script that returns a Flash Slideshow. Is there any way that I can do this? Here is the bit of PHP code that I need to call to return the Flash Slideshow.
<?php
//include slideshow.php to access the Insert_Slideshow function
include "http://mywebsite/slideshow.php";
//insert the slideshow.swf flash file into the web page
//tell slideshow.swf to get the slideshow's data from sample.php created in the first step
//set the slideshow's width to 320 pixels and the height to 240
echo Insert_Slideshow ( "http://mywebsite/slideshow.swf", "http://mywebsite/sample.php", 600, 500 );
?>
To run PHP on your server (not another server) you will definitely need to install a PHP processor.
However since you have a hard-coded URL in there, it looks as though the PHP code is just some kind of utility function for inserting a flash movie.
Run the PHP code on your local computer (for example) and see what HTML it generates, and if it always generates that same HTML, why not just copy it and use that in your website.
You could have the PHP script execute on a PHP enabled webserver somewhere else and include it in an iframe on the page without PHP support. That would be quite ugly, tho.
Although you obviously can't run PHP on a server that doesn't have it, if your slideshow doesn't change frequently perhaps you could run your PHP script on another machine, capture the output, then upload that to your web host.
This is not possible. If you need to call a PHP script, its obvious that you need PHP installed on the web server.

Virtual function - including some html

I have a php-file which includes another html-file:
<? virtual("../top.html");?>
The problem is that any code before this include compiles and runs well, after - nothing. There aren't any errors etc. After commenting this line, everything works.
Code was written under local computer with ArchLinux + LAMP. Now I have ubuntu 10.04 with the same configuration.
What could it be?
You might try changing top.html to top.phtml and using require_once.
<?php require_once('../top.phtml'); ?>
If you just want to pass some html from a file into your output, you could also use:
<?php echo file_get_contents('../top.html'); ?>
That way, you stay independent of the underlying webserver and you make sure, that no php code that may be in the html is being executed.
However if you wish something in there to be executed, you can use require_once() as stated by Jeremy.
Can you check error log of the Apache?
Also, you should use
<?php virtual("../top.html");?>
if your php.ini has short_open_tag = Off.

Categories