Newbie: built a website...some problems...please help!

Hi all,

So I built a website linked with MySQL etc, but there are still some problems. Most of my scripts I wrote separately and then put them all together. When I tried to use the scripts by themselves they worked flawlessly but when I put them together with the color designs and backgrounds etc, problems arose. Is there anyone who is willing to look at it and see if they can help me figure it out???

I’d take a look at things but there isn’t much to see.
I’d say: “Go baby-steps” Don’t add everything in one go, add one thing at a time and see when it breaks.

Also, make sure your settings are set so that errors are shown and not hidden.

Maybe this will help you.
I don’t know if you have an ‘init.php’ or ‘config.php’ that you ALWAYS load (include). If so, put the following in it:
[php]
$DEBUG = true; // Set to ‘false’ if you want the debugging to be quiet
[/php]

Then lace your code with:
[php]
if ( $DEBUG ){ echo “Reached this point: Some useful information about the file and the linenumber
\n”; }
[/php]

If anything actually runs, you can now see what and until where.

Hope this helps,
O.

Yeah I did put everything together slowly but for some reason it all just seemed to develop a couple problems…as in when you go to my forum page from my website you can see there is an error but it isnt there when you are on the home forum page and click the top to go back to the home forum page(as in refresh) then it goes away it is a bit odd.

also on one of the website pages one of the page titles at the top on the navigation bar has mysteriously disappeared but only on that one page.

But then I have a few larger problems where the code just all of a sudden won’t work at all.

Now I am a beginner at this…I haven’t been working on this for very long and I have sort of been teaching myself so I know that I can easily miss something in the code!

Sounds like You have a lot of code to debug here. My best suggestion is to start tearing it down piece by piece. Go through it and section off everything based on what it’s purpose is, and start commenting it out(don’t delete it just add // or /code/) This way you can focus on what’s wrong or have something to post here for us to look at.

Or what I’ve even done before is create a whole new site, and just transfer pieces of code over at a time(making sure everything that’s required of a piece of code is transfered with it) and what works was left, and what didn’t was moved to a “quarantine” until all bugs we’re isolated and made a much easier debugging process. Since then I’ve learned better ways to manage my code to make debugging much much easier and less time consuming however. Sadly there are even better ways I’ve still yet to really get down.

Ok this is the code for one of my problems. This page is supposed to be a testimonials page. The idea is that people would be able to go onto the page post their experiences and ideas etc and once they were sent in they would be posted onto the page so that it looks like another other testimonials page. However when ever I try to use it I can enter in the details, press send and it says that the message has been registered but nothing else shows! Any ideas on how to fix it?

[php]

ul { list-style-type:none; margin:0; padding:0; overflow:hidden; } li { float:left; } a:link,a:visited { display:block; width:120px; font-weight:bold; color:#FFFFFF; background-color:#98bf21; text-align:center; padding:4px; text-decoration:none; text-transform:uppercase; } a:hover,a:active { background-color:#7A991A; }

L. Mo's Photography


Testimonials

<?php
$self = $_SERVER['PHP_SELF']; //get the name of the file
$ipaddress = ("$_SERVER[REMOTE_ADDR]"); //get the users IP Address
include ('connect.php'); //to retrieve database details

// defines a $connect variable, which when used will attempt to connect to the databse using details provided in config.php if it fails, will display error - or die();
//$connect stores a funtion
$connect = mysql_connect($server,$username,$password) or die('<p class="error">Unable to connect to the database server at this time.</p>');

// connect to database using details provided and uses the $connect variable above if it fails, will return error - or die();
mysql_select_db($database,$connect) or die('<p class="error">Unable to connect to the database at this time.</p>');


    //Checks to see if someone has posted something
    if(isset($_POST['send'])) {
        // are any of the fields empty? the || means 'or'
        if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['post'])) {
            echo('<p class="error">You did not fill in a required field.</p>');
        } else {

            // if there are no empty fields, insert into the database:

            // take the 'name' and 'post' parts and run it through htmlspecialchars()
            // to ensure no HTML code is being sent to cause problems
            // and runs through mysql_real_escape_string() to prevent people accessing the database through SQL code.
            $name = htmlspecialchars(mysql_real_escape_string($_POST['name']));
            $email = htmlspecialchars(mysql_real_escape_string($_POST['email']));
            $post = htmlspecialchars(mysql_real_escape_string($_POST['post']));

                // this is our SQL string to insert shouts into db
                $sql = "INSERT INTO shouts SET name='$name', email='$email', post='$post', ipaddress='$ipaddress';";

                    // we run the SQL string now
                    // if it succeeds, display message
                    if (@mysql_query($sql)) {
                        echo('<p class="success">Thanks for shouting!</p>');
                    } else {
                        // if it errors, send message
                        echo('<p class="error">There was an unexpected error when posting your shout.</p>');
                    }
        }
    }

    // now we retrieve the 8 latest shouts from the database
    $query = "SELECT * FROM shouts ORDER BY `id` DESC LIMIT 8;";

    // run the query. if it fails, display error
    $result = @mysql_query("$query") or die('<p class="error">There was an unexpected error grabbing shouts from the database.</p>');

    ?><ul><?
    // while we still have rows from the db, display them
    while ($row = mysql_fetch_array($result)) {

        $ename = stripslashes($row['name']); //removes slashes
        $eemail = stripslashes($row['email']);
        $epost = stripslashes($row['post']);


        echo('<li><div class="meta"><p>'.$ename.'</p></div><div class="shout"><p>'.$epost.'</p></div></li>');

    }
    ?></ul><?

?>

<!-- The actual shoutbox for people to post their comments -->
<form action="<?php $self ?>" method="post">

<div class="fname"><label for="name"><p>Name:</p></label><input name="name" type="text" cols="20" /></div>
<div class="femail"><label for="email"><p>Email:</p></label><input name="email" type="text" cols="20" /></div>
<textarea name="post" rows="5" cols="40"></textarea>
<input name="send" type="hidden" />
<p><input type="submit" value="send" /></p>
</form>
[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service