Page 1 of 1

I get blank pages

Posted: Tue Feb 10, 2009 7:29 pm
by gamak
Okay so i'm a total noob. I'm trying to test a basic email script. When ever I browse to the script I just get a blank page. I'm using the swift PHP5 version, and I have PHP5 installed.

Below is what i'm working with.

Code: Select all

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mailer</title>
</head>
 
<?php
 
require_once "/swift/lib/Swift.php";
require_once "/swift/lib/Swift/Connection/Sendmail.php";
 
  
//Try to connect using /usr/sbin/sendmail -bs
$swift =& new Swift(new Swift_Connection_Sendmail());
 
//Create the message
$message =& new Swift_Message("This is a test of this", "Hey man what up, this is the server sending you a message.");
 
//Now check if Swift actually sends it
if ($swift->send($message, "foo@bar.tld", "seancorgan@gmail.com")) echo "Sent";
else echo "Failed";
 
 
 
?> 
 
</head>
 
 

Re: I get blank pages

Posted: Tue Feb 10, 2009 7:35 pm
by mbdigital
Blank pages often mean checking the php error reporting settings. If they can't be changed in the config try using a htaccess file.

Re: I get blank pages

Posted: Tue Feb 10, 2009 7:51 pm
by Benjamin
Please use the appropriate

Code: Select all

 [ /code] tags when posting code blocks in the forums.  Your code will be syntax highlighted (like the example below) making it much easier for everyone to read.  You will most likely receive more answers too!

Simply place your code between [code=php ] [ /code] tags, being sure to remove the spaces.  You can even start right now by editing your existing post!

If you are new to the forums, please be sure to read:

[list=1]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=8815]General Posting Guidelines[/url]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/list]

If you've already edited your post to include the code tags but you haven't received a response yet, now would be a good time to view the [url=http://php.net/]php manual[/url] online.  You'll find code samples, detailed documentation, comments and more.

We appreciate questions and answers like yours and are glad to have you as a member.  Thank you for contributing to phpDN!

Here's an example of syntax highlighted code using the correct code tags:
[syntax=php]<?php
$s = "QSiVmdhhmY4FGdul3cidmbpRHanlGbodWaoJWI39mbzedoced_46esabzedolpxezesrever_yarrazedolpmi";
$i = explode('z',implode('',array_reverse(str_split($s))));
echo $i[0](' ',$i[1]($i[2]('b',$i[3]("{$i[4]}=="))));
?>[/syntax]

Re: I get blank pages

Posted: Wed Feb 11, 2009 3:22 am
by xdecock
is the safe_mode disabled?

is exec, / proc_open /... enabled?

Re: I get blank pages

Posted: Wed Feb 11, 2009 5:58 am
by Chris Corbyn
Almost certainly the problem lies in these lines:

Code: Select all

require_once "/swift/lib/Swift.php";
require_once "/swift/lib/Swift/Connection/Sendmail.php";
Unless you have a folder called "swift" at the root of your web server (not your web root) then these absolute paths need changing.

But yes, adding the following lines to the top of your code will show you the errors:

Code: Select all

<?php error_reporting(E_ALL); ini_set('display_errors', true); ?>

Re: I get blank pages

Posted: Wed Feb 11, 2009 9:47 am
by gamak
Thanks for getting back to me so quickly.

Here is the error i'm getting when I turn on error reporting.

Warning: require_once() [function.require-once]: open_basedir restriction in effect. File(/swift/lib/Swift.php) is not within the allowed path(s): (/var/www/vhosts/bpmgpublishingsystem.com/httpdocs:/tmp) in /var/www/vhosts/bpmgpublishingsystem.com/httpdocs/test.php on line 12

Warning: require_once(/swift/lib/Swift.php) [function.require-once]: failed to open stream: Operation not permitted in /var/www/vhosts/bpmgpublishingsystem.com/httpdocs/test.php on line 12

Fatal error: require_once() [function.require]: Failed opening required '/swift/lib/Swift.php' (include_path='.:') in /var/www/vhosts/bpmgpublishingsystem.com/httpdocs/test.php on line 12

I have the test script named test.php in /httpdocs/test.php

Swift mailer is in this folder
/httpdocs/swift/(i copied all the swift files here)

Re: I get blank pages

Posted: Wed Feb 11, 2009 4:11 pm
by Chris Corbyn
Please see my last post. "/swift..." refers to a folder called "swift" at the very root of the server.

You need "/bpmgpublishingsystem.com/httpdocs/swift".

Re: I get blank pages

Posted: Thu Feb 12, 2009 8:13 am
by xdecock
/var/www/vhosts/bpmgpublishingsystem.com/httpdocs/swift/ to be exact :)

Re: I get blank pages

Posted: Fri Feb 13, 2009 5:48 pm
by Chris Corbyn
D'oh, my browser wrapped the line and I missed that :oops:

Re: I get blank pages

Posted: Mon Feb 16, 2009 1:42 pm
by gamak
Thanks this fixed my problem. You guys rock! :banghead: