Jump to content

PHP newbie help please.


oalvarado

Recommended Posts

Hello all,

 

I just started a class on MySQL and PHP. Im running Windows 7 pro and Expression Web 2 as an editor, I'm also using filezilla as FTP to acces my school's server.

 

The issue:

 

I work out my text book for my assigment; simply copy the code and summit, we use the server to check our work. When I upload a php file and try check my work i get a blank page, if I upload an HTML or XHTML file I'm able to see the web page with no problems.

 

Here is a simple script out of the book which I get a blank page:

 

[php
<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>variables</title>
</head>

<body>
<?php // Script 2.3 - variables.php

// An address:
$street = "100 Main Street";
$city = "State College";
$state = "PA";
$zip = 16801;

// Print the address.
print "<p>The address is:<br />$street<br />$city $state $zip</P>


</body>

</html>
]
[/code]

 

Can Someone please help me out ? By the way I've tried different editors and I keep getting the same problems.

Link to comment
Share on other sites

Try using the following:

 

<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>variables</title>
</head>

<body>
<?php // Script 2.3 - variables.php

// An address:
$street = "100 Main Street";
$city = "State College";
$state = "PA";
$zip = 16801;

// Print the address.
print "<p>The address is:<br />$street<br />$city $state $zip</p>";

?>

</body>

</html>

 

You forgot to end your PHP code island (note how the color of this code changes from black and white (html) to colored (PHP)).

Link to comment
Share on other sites

ok I fixe'd it but no joy, same problem. I tried adding another ? to the following line:

<?php? // Script 2.3 - variables.php

 

my script changed color to red and blue and I was able to get a page on the browser to display address, street, city and zip but not the variables I needed.

Link to comment
Share on other sites

ok I fixe'd it but no joy, same problem. I tried adding another ? to the following line:

<?php? // Script 2.3 - variables.php

 

my script changed color to red and blue and I was able to get a page on the browser to display address, street, city and zip but not the variables I needed.

Nah, there is only supposed to be one ? in the opening of the php script. He means that after all the php you have to tell the page your done with php and to just go back to html, by using a "?>". Try this :

 

<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>variables</title>
</head>

<body>

<?php // Script 2.3 - variables.php
// An address:
$street = "100 Main Street";
$city = "State College";
$state = "PA";
$zip = 16801;

// Print the address.
print "<p>The address is:<br />$street<br />$city $state $zip</p>";

?>

</body>

</html>

 

I just tried it out and it works fine like this. :) Hope you understand the changes. I also had to add the end quote sign and the semicolon at the end of the last print command.

Link to comment
Share on other sites

Thanks guys,

 

I keep getting a blank page from the server, I think my problem is at the other end ( server) cause I've tried different editors in the past hour and I keep getting the same result. I've tried Notepad++, Alleycode and MS Expression Web 2 all with the same result, a blank page. 

Link to comment
Share on other sites

I tried Impotune's code, I get the same blank page

 

<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>variables</title>
</head>
<body>
<?php // Script 2.3 - variables.php
// An address:
$street = "100 Main Street";
$city = "State College";
$state = "PA";
$zip = 16801;
// Print the address.
print "<p>The address is:<br />$street<br />$city $state $zip</p>";
?>
</body>
</html>

 

I dont know what else to do

Link to comment
Share on other sites

I tried Impotune's code, I get the same blank page

 

<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>variables</title>
</head>
<body>
<?php // Script 2.3 - variables.php
// An address:
$street = "100 Main Street";
$city = "State College";
$state = "PA";
$zip = 16801;
// Print the address.
print "<p>The address is:<br />$street<br />$city $state $zip</p>";
?>
</body>
</html>

 

I dont know what else to do

 

 

Well, just to verify I copied that exact code again into a new file, saved it as "add.php", and then put it on my server and it opens beautifully. Perhaps you should try installing php to your computer, and then opening it from your localhost. An easy way to do that would be to use WAMP to install everything.

 

Otherwise, you could just show it to your professor and tell him/her that its giving you a blank page. He'll give you credit for that script, if thats what your worried about. It works.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.