Jump to content

Blank Page


Russia

Recommended Posts

I am currently getting a blank page, and no errors are showing up.

 

<?php
//The script must connect to DB FIRST!
require("../inc/config.php");

$result = mysql_query("select count(*) as rowcount from notes");
$Count = mysql_result($result, 0);
echo "<div style=\"text-align:right\">Number of Members: $Count</div>";


if (isset($_POST['del']))
{
    if(isset($_POST['delchk']))
    {
        for($count=0;$count<count($_POST['delchk']);$count++)
        {
            $delete = $_POST['delchk'][$count];
            $query = "DELETE FROM `persons` WHERE id = '$delete'";
            $result = mysql_query($query);
            if (!$result)
            {
                die("Error deleting persons! Query: $query<br />Error: ".mysql_error());
            }
        }
    }
    else
    {
        echo "delchk post variable not set";
    }
}
else
{
    echo "del post variable not set";
}

$result = mysql_query("SELECT * FROM persons");
// Check how many rows it found
if(mysql_num_rows($result) > 0)
{
    echo "<table id=\"mytable\">
    <thead>
    <tr>
    <th align=\"center\" scope=\"col\">Delete</th>
    <th align=\"center\" scope=\"col\">First Name</th>
    <th align=\"center\" scope=\"col\">Last Name</th>
    <th align=\"center\" scope=\"col\">Profile</th>
    <th align=\"center\" scope=\"col\">Date of Entry</th>
    <th align=\"center\" scope=\"col\">IP Address</th>
    </tr>
    </thead>
    <tbody>";

    echo "<form name = 'myform' action='' method='post'>";
    while($row = mysql_fetch_array($result))
    {
        echo "<tr align=\"center\">";
        echo'<td><inputtype=\"checkbox\"id=\"delchk\"name=\"delchk[]\"value=\"$row['id']\"/></td>';
        echo "<td>" . $row['FirstName'] . "</td>";
        echo "<td>" . $row['LastName'] . "</td>";
        echo "<td><a target=frame2 href='" ."profile.php?user1=". $row['FirstName'] ."'>Check HighScores</a></td>";
        echo "<td>" . $row['AddedDate'] . "</td>";
        echo "<td>" . $row['Ip'] . "</td>";
        echo "</tr>";
    }
    echo "</tbody>";
    echo "</table>";
    echo "<hr>";
    echo "<input type='submit' name = 'del' value='Delete Selected'></form>";
    echo "<input type='button' onclick='checkall(document.myform.delchk);' value='Select All'>";
    echo "<input type='button' onclick='uncheckall(document.myform.delchk);' value='UnSelect All'>";
}
else
{
    // No rows were found ...
    echo "
    <table id=\"mytable\">
    <thead>
    
    <tr>
    <th align=\"center\" scope=\"col\">Delete</th>
    <th align=\"center\" scope=\"col\">First Name</th>
    <th align=\"center\" scope=\"col\">Last Name</th>
    <th align=\"center\" scope=\"col\">Profile</th>
    <th align=\"center\" scope=\"col\">Date of Entry</th>
    <th align=\"center\" scope=\"col\">IP Address</th>
    </tr>
    </thead>
    <tbody>";
    echo "</tbody>";
    echo "</table>";
}

mysql_close();
?> 

Link to comment
Share on other sites

Done:

 

<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);

//The script must connect to DB FIRST!
require("../inc/config.php");

$result = mysql_query("select count(*) as rowcount from notes");
$Count = mysql_result($result, 0);
echo "<div style=\"text-align:right\">Number of Members: $Count</div>";


if (isset($_POST['del']))
{
    if(isset($_POST['delchk']))
    {
        for($count=0;$count<count($_POST['delchk']);$count++)
        {
            $delete = $_POST['delchk'][$count];
            $query = "DELETE FROM `persons` WHERE id = '$delete'";
            $result = mysql_query($query);
            if (!$result)
            {
                die("Error deleting persons! Query: $query<br />Error: ".mysql_error());
            }
        }
    }
    else
    {
        echo "delchk post variable not set";
    }
}
else
{
    echo "del post variable not set";
}

$result = mysql_query("SELECT * FROM persons") or die("error retrieving persons".mysql_error());
// Check how many rows it found
if(mysql_num_rows($result) > 0)
{
    echo "<table id=\"mytable\">
    <thead>
    <tr>
    <th align=\"center\" scope=\"col\">Delete</th>
    <th align=\"center\" scope=\"col\">First Name</th>
    <th align=\"center\" scope=\"col\">Last Name</th>
    <th align=\"center\" scope=\"col\">Profile</th>
    <th align=\"center\" scope=\"col\">Date of Entry</th>
    <th align=\"center\" scope=\"col\">IP Address</th>
    </tr>
    </thead>
    <tbody>";

    echo "<form name = 'myform' action='' method='post'>";
    while($row = mysql_fetch_array($result))
    {
        echo "<tr align=\"center\">";
        echo'<td><inputtype=\"checkbox\"id=\"delchk\"name=\"delchk[]\"value=\"$row['id']\"/></td>';
        echo "<td>" . $row['FirstName'] . "</td>";
        echo "<td>" . $row['LastName'] . "</td>";
        echo "<td><a target=frame2 href='" ."profile.php?user1=". $row['FirstName'] ."'>Check HighScores</a></td>";
        echo "<td>" . $row['AddedDate'] . "</td>";
        echo "<td>" . $row['Ip'] . "</td>";
        echo "</tr>";
    }
    echo "</tbody>";
    echo "</table>";
    echo "<hr>";
    echo "<input type='submit' name = 'del' value='Delete Selected'></form>";
    echo "<input type='button' onclick='checkall(document.myform.delchk);' value='Select All'>";
    echo "<input type='button' onclick='uncheckall(document.myform.delchk);' value='UnSelect All'>";
}
else
{
    // No rows were found ...
    echo "
    <table id=\"mytable\">
    <thead>
    
    <tr>
    <th align=\"center\" scope=\"col\">Delete</th>
    <th align=\"center\" scope=\"col\">First Name</th>
    <th align=\"center\" scope=\"col\">Last Name</th>
    <th align=\"center\" scope=\"col\">Profile</th>
    <th align=\"center\" scope=\"col\">Date of Entry</th>
    <th align=\"center\" scope=\"col\">IP Address</th>
    </tr>
    </thead>
    <tbody>";
    echo "</tbody>";
    echo "</table>";
}

mysql_close();
?> 

Link to comment
Share on other sites

$result = mysql_query($query);

if (!$result)

 

only tells you the query did not contain any errors. To make sure the query did actually something use:

 

$result = mysql_query($query);

if ($result && mysql_affected_rows($result))

 

Make sure the query was successfull (you need it otherwise the latter will throw an error if didn't) and second make sure it did something (update a table, delete a record, ..)

Link to comment
Share on other sites

The posted code (the last version posted) contains a fatal parse error -

 

Parse error: parse error, expecting `','' or `';'' in your_file.php on line 59

 

Please, please, please learn php, develop php code, and debug php code on a system with error_reporting set to E_ALL and display_errors set to ON in your php.ini to get php to help you. Fatal parse errors prevent your code from executing and trying to set those two values in your code won't do anything for a parse error because the code is never executed to set the values. Stop and start your web server to get any change made to php.ini and confirm the actual values using a phpinfo(); statement.

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.