Groups

    PHP Help!

    Hello I have just started to learn myself PHP from a book and I've just followed what it said to do and now all I get is a white page... I've checked over the book and my code is exactly like it is in the book so I am looking for somebody who knows some PHP to help me out please.
    Thanks

    35 Comments

    Which programme you using to write it? Dreamweaver?

    Original Poster

    Yeah i'm using Dreamweaver but typing in the code myself if that makes sense. Basically when I put this into the top of the PHP code I get a white page.

    The code I'm trying to put in is:

    $meta = &new Meta;

    $meta->company_name = "My Company";
    $meta->description = "This is my first PHP enabled website";
    $meta->keywords2 = "PHP, MySQL, Web Development";
    $meta->sitename = "My PHP Site";
    $meta->slogan = "Be Patient, I'm Learning";
    $meta->generator = "PHP";

    jennyrocks;2865554

    Yeah i'm using Dreamweaver but typing in the code myself if that makes … Yeah i'm using Dreamweaver but typing in the code myself if that makes sense. Basically when I put this into the top of the PHP code I get a white page.The code I'm trying to put in is:$meta = &new Meta;$meta->company_name = "My Company";$meta->description = "This is my first PHP enabled website";$meta->keywords2 = "PHP, MySQL, Web Development";$meta->sitename = "My PHP Site";$meta->slogan = "Be Patient, I'm Learning";$meta->generator = "PHP";



    thats meta tags, which only are seen by search engines, it won't show on a web page

    jennyrocks;2865554

    Yeah i'm using Dreamweaver but typing in the code myself if that makes … Yeah i'm using Dreamweaver but typing in the code myself if that makes sense. Basically when I put this into the top of the PHP code I get a white page.The code I'm trying to put in is:$meta = &new Meta;$meta->company_name = "My Company";$meta->description = "This is my first PHP enabled website";$meta->keywords2 = "PHP, MySQL, Web Development";$meta->sitename = "My PHP Site";$meta->slogan = "Be Patient, I'm Learning";$meta->generator = "PHP";




    Cant really think at mo as half asleep!! Is that all you got on the page? As you need to open and close the php script?

    Original Poster

    faevilangel;2865575

    thats meta tags, which only are seen by search engines, it won't show on … thats meta tags, which only are seen by search engines, it won't show on a web page



    Yeah I know that but it is on a page that has content, the page works fine without the meta code but with it just shows a white page.

    jennyrocks;2865616

    Yeah I know that but it is on a page that has content, the page works … Yeah I know that but it is on a page that has content, the page works fine without the meta code but with it just shows a white page.



    i can't see the problem but try using this way of doing meta tags

    echo \"n\";

    using the echo command you can insert HTML tags

    Banned

    jennyrocks;2865616

    Yeah I know that but it is on a page that has content, the page works … Yeah I know that but it is on a page that has content, the page works fine without the meta code but with it just shows a white page.



    That PHP code in itself does nothing, it may even generate an error. Are you sure that you haven't missed a slice of code from a previous page or example?

    beelzebub;2865711

    That PHP code in itself does nothing, it may even generate an error. Are … That PHP code in itself does nothing, it may even generate an error. Are you sure that you haven't missed a slice of code from a previous page or example?



    double check you have <?php at start and ??> at end :thumbsup:

    Original Poster

    faevilangel;2865687

    i can't see the problem but try using this way of doing meta tags echo … i can't see the problem but try using this way of doing meta tags echo \"n\";using the echo command you can insert HTML tags



    Hi thanks for replying I have pasted this into my code and it has made the ?> not work and displayed another white screen.

    The way i've done the coding so far is to have a template layout made and then my index file is just pure php that calls the template and fills it. It also calls a class file that the uses the meta data to put it in html tags. Again my code for the class is the same as the book and isn't working.

    I've found the same chapter from the book online if that helps; It is ultimatephp.blogspot.com/200…tml

    I've followed the code exactly and from the clsMetaContent.php it isn't working

    jennyrocks;2865801

    Hi thanks for replying I have pasted this into my code and it has made … Hi thanks for replying I have pasted this into my code and it has made the ?> not work and displayed another white screen.The way i've done the coding so far is to have a template layout made and then my index file is just pure php that calls the template and fills it. It also calls a class file that the uses the meta data to put it in html tags. Again my code for the class is the same as the book and isn't working.I've found the same chapter from the book online if that helps; It is http://ultimatephp.blogspot.com/2007/11/chapter-4-building-website-template.htmlI've followed the code exactly and from the clsMetaContent.php it isn't working



    ok whats your reason for using php ? unless your using MYsql or for security , it has not much use........

    you can write most of the php stuff using html .......

    e.g.

    <?php
    include the html tags here ........

    ?>

    i use php as no one can steal your code when its php, as its not stored locally...... (stored on the server)

    i too have learnt php from a book but prefer using [url]www.w3schools.com/php[/url]

    Original Poster

    Well I plan to make a turn based PHP, MySQL game (when I know how lol!) like monstersgame.co.uk/
    It will take some time to learn everything I know but I am quite good at various programming languages once I've got the hang of them.

    Banned

    I found this particular chapter online (pdf form) and in my opinion it's poorly written, very easy to get confused.

    Is that piece of code meant to be an array? If so Ive never seen an array constructed like that before, however im no PHP expert.

    jennyrocks;2865939

    Well I plan to make a turn based PHP, MySQL game (when I know how lol!) … Well I plan to make a turn based PHP, MySQL game (when I know how lol!) like http://www.monstersgame.co.uk/It will take some time to learn everything I know but I am quite good at various programming languages once I've got the hang of them.



    ahhh ok, i can help you with the php coding if you need,........ you would want a login form? a database to store users data, their "level" etc...... its tough to make in php but its fun :-D

    razta;2866045

    Is that piece of code meant to be an array? If so Ive never seen an array … Is that piece of code meant to be an array? If so Ive never seen an array constructed like that before, however im no PHP expert.



    no they are meta tqags - they show a search engine what the site is about ..... its a easy way to get google to notice your content and get a better ranking

    Original Poster

    faevilangel;2866125

    ahhh ok, i can help you with the php coding if you need,........ you … ahhh ok, i can help you with the php coding if you need,........ you would want a login form? a database to store users data, their "level" etc...... its tough to make in php but its fun :-D



    Thanks that would be great, Sounds like you've made one yourself?
    Yeah login form, database, file handling etc.
    My favourite programming language is vb.net I'm learning Java atm which is useful. What's your favourite language?
    Do you know of any good PHP books? I think the fastest way of learning a prog language is by following really simple tutorials and evolving them into your own.

    jennyrocks;2866205

    Thanks that would be great, Sounds like you've made one yourself?Yeah … Thanks that would be great, Sounds like you've made one yourself?Yeah login form, database, file handling etc. My favourite programming language is vb.net I'm learning Java atm which is useful. What's your favourite language? Do you know of any good PHP books? I think the fastest way of learning a prog language is by following really simple tutorials and evolving them into your own.



    i only use web based languages (and preferably not made by microsoft)

    i know php, javascript, c++, css, html, ajax, some C, im going to learn ASP soon though:thumbsup:

    Original Poster

    I'm looking to learn ajax if I find a use for it to be implemented in to my site.

    I don't get what's going on with it now, I've just made a simple sign up form and when I add validation code it gives me the white screen instead of the sign up form! I've found that it so far is when i put the following code...

    $error = true;
    $errors .= "Form Input Errors:"."\n\n"

    Is that the right format etc? It's the first instance of both vars so have I created them correctly?
    Thanks again

    jennyrocks;2866977

    I'm looking to learn ajax if I find a use for it to be implemented in to … I'm looking to learn ajax if I find a use for it to be implemented in to my site.I don't get what's going on with it now, I've just made a simple sign up form and when I add validation code it gives me the white screen instead of the sign up form! I've found that it so far is when i put the following code...$error = true;$errors .= "Form Input Errors:"."\n\n"Is that the right format etc? It's the first instance of both vars so have I created them correctly?Thanks again



    you have a dot in there and you don't have an end ; on the second line
    all php code needs to finish with a ;

    Original Poster

    the .= is on all of the $errors
    added the ; I know all lines apart from { need to be ;'d from java just always miss one out lol!
    Still white screen tho... is it something to do with declaring the vars? I'm lost at this point!!

    jennyrocks;2867018

    the .= is on all of the $errors :Sadded the ; I know all lines apart from … the .= is on all of the $errors :Sadded the ; I know all lines apart from { need to be ;'d from java just always miss one out lol!Still white screen tho... is it something to do with declaring the vars? I'm lost at this point!!



    whats the full code you have ?

    Original Poster


    include $_SERVER['DOCUMENT_ROOT'].'/layout1.php';

    switch($_REQUEST['req']){

    case "process";
    myheader("Become a Member!!");

    //Validate all required fields were posted
    if(!$_POST['first_name'] ||
    !$_POST['last_name'] ||
    !$_POST['email_address'] ||
    !$_POST['email_address2'] ||
    !$_POST['username'] ||
    !$_POST['password'] ||
    !$_POST['password2'] ||
    !$_POST['bio'] ||){

    $error = true;
    $errors .= "Form Input Errors:"."\n\n;"

    if(!$_POST['first_name']){
    $errors .= "Missing First Name\n";
    }
    if(!$_POST['last_name']){
    $errors .= "Missing Last Name\n";
    }
    if(!$_POST['email_address']){
    $errors .= "Missing Email Address\n";
    $email_error = true;
    }
    if(!$_POST['email_address2']){
    $errors .= "Missing Email Address2\n";
    $email_error = true;
    }
    if(!$_POST['username']){
    $errors .= "Missing Username\n";
    }
    if(!$_POST['password']){
    $errors .= "Missing Password\n";
    $password_error = true;
    }
    if(!$_POST['password2']){
    $errors .= "Missing Password Verification\n";
    $password_error = true;
    }
    if(!$_POST['bio']){
    $errors .= "Missing Bio\n";
    }
    }

    //If both emails were posted, validate they match
    if($email_error == false){
    if($_POST['email_address'] != $_POST['email_address2']){
    $error = true;
    $errors .= "Email addresses do not match!\n\n";
    $email_error = true;
    }
    }

    //If both passwords were posted, validate they match
    if($password_error == false){
    if($_POST['password'] != $_POST['password2']){
    $error = true;
    $errors .= "Passwords do not match!\n\n";
    $password_error = true;
    }
    }

    if($email_error == false){
    // Verify if email address has been used already
    $ecount = mysql_result(mysql_query("SELECT COUNT(*) AS ecount FROM members WHERE
    email_address = '[$_POST['email_address'])'"),0;

    // If email exists, genorate error and message
    if($ecount > 0){
    $error = true;
    $errors .= "This email has already ".
    "been used ".
    "please reset your password.\n\n";
    }
    }

    // Verify if username has been used already
    $ucount = mysql_result(mysql_query("SELECT COUNT(*) AS ucount FROM members WHERE
    username = '[$_POST['username'])'"),0;

    // If username exists, genorate error and message
    if($ucount > 0){
    $error = true;
    $errors .= "Username already exists, ".
    "please choose another.\n\n";
    }
    }

    // If $error is TRUE, then include the signup form
    // and display the errors
    if($error == true){
    $errors = nl2br($errors);
    include $_SERVER['DOCUMENT_ROOT'].'/html/forms/signup.html';
    footer();
    exit();
    }

    // All checks have passed, insert user to database

    // Email User

    // Email Admin

    break;

    default:
    myheader("Become a Member!");
    include $_SERVER['DOCUMENT_ROOT'].'/html/forms/signup.html';
    footer();
    break;

    }
    ?>

    jennyrocks;2867057

    include … include $_SERVER['DOCUMENT_ROOT'].'/layout1.php';switch($_REQUEST['req']){case "process";myheader("Become a Member!!");//Validate all required fields were postedif(!$_POST['first_name'] ||!$_POST['last_name'] ||!$_POST['email_address'] ||!$_POST['email_address2'] ||!$_POST['username'] ||!$_POST['password'] ||!$_POST['password2'] ||!$_POST['bio'] ||){$error = true;$errors .= "Form Input Errors:"."\n\n;"if(!$_POST['first_name']){$errors .= "Missing First Name\n";}if(!$_POST['last_name']){$errors .= "Missing Last Name\n";}if(!$_POST['email_address']){$errors .= "Missing Email Address\n";$email_error = true;}if(!$_POST['email_address2']){$errors .= "Missing Email Address2\n";$email_error = true;}if(!$_POST['username']){$errors .= "Missing Username\n";}if(!$_POST['password']){$errors .= "Missing Password\n";$password_error = true;}if(!$_POST['password2']){$errors .= "Missing Password Verification\n";$password_error = true;}if(!$_POST['bio']){$errors .= "Missing Bio\n";}}//If both emails were posted, validate they matchif($email_error == false){if($_POST['email_address'] != $_POST['email_address2']){$error = true;$errors .= "Email addresses do not match!\n\n";$email_error = true;}}//If both passwords were posted, validate they matchif($password_error == false){if($_POST['password'] != $_POST['password2']){$error = true;$errors .= "Passwords do not match!\n\n";$password_error = true;}}if($email_error == false){// Verify if email address has been used already$ecount = mysql_result(mysql_query("SELECT COUNT(*) AS ecount FROM members WHERE email_address = '[$_POST['email_address'])'"),0;// If email exists, genorate error and messageif($ecount > 0){$error = true;$errors .= "This email has already "."been used "."please reset your password.\n\n";}}// Verify if username has been used already$ucount = mysql_result(mysql_query("SELECT COUNT(*) AS ucount FROM members WHERE username = '[$_POST['username'])'"),0;// If username exists, genorate error and messageif($ucount > 0){$error = true;$errors .= "Username already exists, "."please choose another.\n\n";}}// If $error is TRUE, then include the signup form// and display the errorsif($error == true){$errors = nl2br($errors);include $_SERVER['DOCUMENT_ROOT'].'/html/forms/signup.html';footer();exit();}// All checks have passed, insert user to database// Email User// Email Adminbreak;default:myheader("Become a Member!");include $_SERVER['DOCUMENT_ROOT'].'/html/forms/signup.html';footer();break;}?>



    ok try something, works for me on your includes change them to

    include ('filename.php');

    Original Poster

    I've just changed it and still white page, when I have this code it works.

    <?php

    include ('layout1.php');

    switch($_REQUEST['req']){
    case "process";
    myheader("Become a Member2!");

    echo $_POST['username'];

    //Validate all required fields were posted
    if(!$_POST['first_name'] ||
    !$_POST['last_name'] ||
    !$_POST['email_address'] ||
    !$_POST['email_address2'] ||
    !$_POST['username'] ||
    !$_POST['password'] ||
    !$_POST['password2'] ||
    !$_POST['bio']){

    //$error = true;
    //$errors .= "Form Input Errors:"."\n\n;"

    if(!$_POST['first_name']){
    $errors .= "Missing First Name\n";
    }
    if(!$_POST['last_name']){
    $errors .= "Missing Last Name\n";
    }
    if(!$_POST['email_address']){
    $errors .= "Missing Email Address\n";
    $email_error = true;
    }
    if(!$_POST['email_address2']){
    $errors .= "Missing Email Address2\n";
    $email_error = true;
    }
    if(!$_POST['username']){
    $errors .= "Missing Username\n";
    }
    if(!$_POST['password']){
    $errors .= "Missing Password\n";
    $password_error = true;
    }
    if(!$_POST['password2']){
    $errors .= "Missing Password Verification\n";
    $password_error = true;
    }
    if(!$_POST['bio']){
    $errors .= "Missing Bio\n";
    }
    }





    break;

    default:
    myheader("Become a Member!");
    include ('signup.html');
    footer();
    break;
    }
    ?>

    Stripped down version and $error / $errors commented out

    Original Poster

    With the Stripped down version it works with just $errors commented out so it must be something to do with that var?

    jennyrocks;2867095

    I've just changed it and still white page, when I have this code it … I've just changed it and still white page, when I have this code it works.include ('layout1.php');switch($_REQUEST['req']){case "process";myheader("Become a Member2!");echo $_POST['username'];//Validate all required fields were postedif(!$_POST['first_name'] ||!$_POST['last_name'] ||!$_POST['email_address'] ||!$_POST['email_address2'] ||!$_POST['username'] ||!$_POST['password'] ||!$_POST['password2'] ||!$_POST['bio']){//$error = true;//$errors .= "Form Input Errors:"."\n\n;"if(!$_POST['first_name']){$errors .= "Missing First Name\n";}if(!$_POST['last_name']){$errors .= "Missing Last Name\n";}if(!$_POST['email_address']){$errors .= "Missing Email Address\n";$email_error = true;}if(!$_POST['email_address2']){$errors .= "Missing Email Address2\n";$email_error = true;}if(!$_POST['username']){$errors .= "Missing Username\n";}if(!$_POST['password']){$errors .= "Missing Password\n";$password_error = true;}if(!$_POST['password2']){$errors .= "Missing Password Verification\n";$password_error = true;}if(!$_POST['bio']){$errors .= "Missing Bio\n";}}break;default:myheader("Become a Member!");include ('signup.html');footer();break;}?>Stripped down version and $error / $errors commented out



    how old is that book :whistling: what php does it cover e.g. 4.3???

    php is now nearing version 6 :? i would reccomend using [url]www.w3schools.com/php[/url] to learn from ..... its up to date, (unlike a lot of books) also use [url]www.php.net[/url] to help with any errors

    Original Poster

    lol the book is from 2003 and covers 4.3.x

    I assumed it would be the same coding I've got PHP 5.2.6 installed.

    Does this makes loads of difference?? :O

    jennyrocks;2867129

    lol the book is from 2003 and covers 4.3.xI assumed it would be the same … lol the book is from 2003 and covers 4.3.xI assumed it would be the same coding I've got PHP 5.2.6 installed.Does this makes loads of difference?? :O



    a lot of commands from php 4 is now defunct in 5.2

    some of the commands are the same but many are not...... thats why i use web pages :-D

    Original Poster

    Glad I found this out now and not after a few weeks haha I'm gonna just read everything on the w3schools site like I did with html lol.
    Thanks for your help, gonna get some kip and then try again tomorrow :D.
    Will post in this thread again if I get stuck, if you don't mind would you drop in again and see if you can find anything i'm doing wrong if I get stuck agian please?

    jennyrocks;2867168

    Glad I found this out now and not after a few weeks haha I'm gonna just … Glad I found this out now and not after a few weeks haha I'm gonna just read everything on the w3schools site like I did with html lol.Thanks for your help, gonna get some kip and then try again tomorrow :D.Will post in this thread again if I get stuck, if you don't mind would you drop in again and see if you can find anything i'm doing wrong if I get stuck agian please?



    im around too much so course i will, or just pm me ;-) so i can feel loved :whistling::p

    TBH if you are doing a lot of logic rather than front end, you'd be better off using a IDE (as it will show synatactic errors in code).
    Netbeans is a pretty good IDE - and recently has added support for PHP.
    netbeans.org/kb/…tml
    Also if you are designing a database backend, take some time to plan it out before you begin coding, as it can be a pain in the ass. I wouldn't recommend using PHP to set up the tables, instead use a specialised tool like MySQLAdmin to begin with

    MoneySavingG;2869187

    TBH if you are doing a lot of logic rather than front end, you'd be … TBH if you are doing a lot of logic rather than front end, you'd be better off using a IDE (as it will show synatactic errors in code). Netbeans is a pretty good IDE - and recently has added support for PHP. http://www.netbeans.org/kb/docs/php/php-editor-screencast.htmlAlso if you are designing a database backend, take some time to plan it out before you begin coding, as it can be a pain in the ass. I wouldn't recommend using PHP to set up the tables, instead use a specialised tool like MySQLAdmin to begin with



    i use php to write my tables & it works well....... mysqladmin is trash compared to PHPmyadmin

    faevilangel;2870281

    i use php to write my tables & it works well....... mysqladmin is trash … i use php to write my tables & it works well....... mysqladmin is trash compared to PHPmyadmin



    Lol yeah, I always get those two mixed up. I'm usually do my stuff in postgresql, because I'm so used to it now.
    Really, I don't like all those DB admin tools. It's a lot better to sit down with a pen and paper, and draw up the database as a entity-relationship model. Then you can work directly with the database shell by using it's native commands.

    Original Poster

    I've done a bit more of PHP now and can understand it more but this Meta script it still not working

    I've found out that certain lines are making the page show a white screen but cannot see what is wrong with the lines in question

    $meta = new Meta;
    <?php echo $meta-?>metadata($ptitle); ?>

    Can anybody see anything wrong with these two lines? The first is in a different <?php ??> so it is closed etc without the two lines the page works fine and displays the page correctly.

    I want to move on and learn more but this is really bugging me lol.

    you have an outdated book so gonna be hard for ya

    here is the code to do it right (i think) (i had to google this)

    <?php
    $tpTitle="Helping you to improve your web site";
    $pgHeading="Site-Report.com - Helping you to improve your web site";
    $pgDesc="Helping you to improve your web site";
    $pgKeywords="site-report";
    ?>
    Post a comment
    Avatar
    @
      Text
      Top Discussions
      1. Are these two things distinctly different to you?2384
      2. 'Hard' Brexit offers '£135bn annual boost' to economy - BBC News1014
      3. 75% off Sky TV for existing customers. Only works when you call the specifi…17416151
      4. How dangerous is Donald trump?33201

      See more discussions