1

Ok, I have a gallery that's being populated by a database but for some reason it's not pulling entries from beyond May 31st 2011. I've scoured the code and can't find any date limitations so I'm at a loss as to why it's not pulling in any recent entries.

I've also looked through the database table and don't see any irregularities between pre May31st and more current entries.

<?php
//GALLERY PAGE
$user="USER";
$password = "PASSWORD";
$database = "GALLERY";
$hostname_portfolio ="localhost:3306";

//gets the page number from the URL

if($_GET["pageNum"]==''){
$listedNum=0;

//gets the page limit from the URL
$limit=5;
}

else{
$listedNum=$_GET["pageNum"];

//gets the page limit from the URL
$limit=$_GET["limit"];

}
//creates the list of projects and puts them into an array
$project= array();

$con = mysql_connect($hostname_portfolio,$user,$password);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$dbcon = mysql_select_db("GALLERY", $con);
if (!$dbcon)
  {
  die('Could not connect: ' . mysql_error());
  }
  if ($dbcon)
  {
  }

 mysql_select_db($database, $con);

$result = mysql_query("SELECT * FROM Persons ORDER BY date_uploaded DESC");


  echo"<div class='clear' style='clear:both;'></div>";

$j=0;
do{
  if($row['approved']=="true"){
    $project[$j] = 
        "<div class='project-list'>
            <div class='user-project'>
                <div class='container'>
                    <div class='before-box' >
                        <p class='picture_state'>Before</p>
                        <a href='http://THEURL.com/". $row['image_path']."'>
                        <img src= '". $row['image_path']. "' width='400px' height='300px'/></a>
                        <br />
                    </div>
                    <div class='after-box'>
                        <p class='picture_state'>After</p>
                        <a href='". $row['picture_state']."'>
                        <img src= '". $row['picture_state']. "' width='400px' height='300px' /></a>
                        <br />
                    </div>
                    <div class='sidebox'>
                        <div class='inner-sidebox'>
                            <p class='date-project'>
                                Submitted by " . $row['FirstName'] . " " . $row['LastName']. " on " .$row['date_uploaded']. "</p>
                            <p> " .$row['decription']. "</p>";
            if($row['ATTR1'] || $row['ATTR2']){ 
                $project[$j] .= "<p>Used "; 
                if ($row['ATTR1']){ 
                    $project[$j] .= "PRODUCT2&trade;"; 
                    if ($row['color1']){ 
                        $project[$j] .= " in " . $row['color1']; 
                    }
                    if ($row['ATTR2']){
                        $project[$j] .= " and ";  
                    }   
                }
                if($row['ATTR2']){ 
                    $project[$j] .= "PRODUCT<sup>&reg;</sup>"; 
                    if ($row['color2']){ 
                        $project[$j] .= " in " . $row['color2']; 
                    }
                }
                $project[$j] .= "</p>"; 
            }
            $project[$j] .= "
                        </div>
                    </div>
                </div>
                <div class='clear' style='clear:both;'>
                </div>
            </div>
            <div class='clear' style='clear:both;'>
            </div>
        </div>
        <div class='clear' style='clear:both;'>
        </div>";
        $j++; 
}

}

while($row = mysql_fetch_array($result));

$max=sizeof($project);

for($i=$listedNum;$i<$limit;$i++){

echo $project[$i];

}


$max=sizeof($project) - 1;

echo "<div class='bottom' style='width:170px;margin:0px auto;'>";

if($listedNum > 0){
    $prevPageNum=$listedNum - 5;
    $lastPage= $limit - 5;
    echo "<a href='http://THEURL.com/gallery.php?    pageNum=".$prevPageNum."&limit=".$lastPage."'>< Last Page </a>";   
}
else{
$prevPageNum=$listedNum;
$lastPage= $limit;
}
echo"&nbsp;&nbsp;";
if($limit <= $max){

$newPageNum=$listedNum + 5;
$nextPage= $limit + 5;
echo "<a href='http://THEURL.com/gallery.php?pageNum=".$newPageNum."&limit=".$nextPage."'> Next Page ></a>";    

}

else{
    $newPageNum=$listedNum;
    $nextPage= $limit;
}

echo "</div>";

mysql_close($con);
?> 
2
  • did you write that diabolicalness? Commented Aug 2, 2011 at 21:04
  • 1
    Nope, a crappy contractor... Which is probably why it broke. I'm front-end and have limited PHP experience which is why I'm asking for help. Commented Aug 2, 2011 at 21:06

4 Answers 4

1

Im going to guess that its one of the following:

  1. Youre server is only allowing you to pull 'x' amount of rows within each query (and that 'x' is dont at may 31st')

  2. or theres something different with the files after may 31st. compared to the ones earlier

Sign up to request clarification or add additional context in comments.

Comments

0

There's nothing in the code. It might be the way your database is configured where it only lets a certain number of results be returned and that happens to coincide with the date.

3 Comments

I found an entry in the Server Variables and Setting that reads: "delayed insert limit 100" 100 happens to be the number of entries that are being displayed. Is this a setting that needs to be changed?
I wouldn't say it needs to be changed, it depends what you use your sever for. If you don't fancy playing about with config files then you could always do another where SELECT * ORDER BY id DESC LIMIT 101, 100 (needs checking) which will select the next 100.
Perfect Josh. I took your tip and learned a dash of MySQL to alter the query in the php. It's working now!
0

Check data in table. May be, after may 31st it was not "approved" ("approved" field was not set to something that casts to boolean TRUE)

1 Comment

Yeah, the newer entries are set to TRUE in the approved column.
0

Judging from your code - either date_uploaded is null in the records after May 31 or something else is wrong in your DB. Approved not equaling true on the offending records, for example.

Failing that, maybe it has something to do with this limitation. Try passing in a number higher than 5 and see if you get more records showing.

//gets the page number from the URL

if($_GET["pageNum"]==''){
$listedNum=0;

//gets the page limit from the URL
$limit=5;
}

else{
$listedNum=$_GET["pageNum"];

//gets the page limit from the URL
$limit=$_GET["limit"];

}

1 Comment

I checked the table. All approved new entries are set to TRUE and do contain a valid date_uploaded.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.