...

View Full Version : Pagination not working



UrbanTwitch
08-13-2008, 08:43 PM
Ok so I am trying to make a pagination for my site. For my members and my inbox.

I got it working good by itself with no WHERE = '$logged[username]'.

I take
$sql = mysql_query("SELECT * FROM privates LIMIT ".$limits.",$max") or die(mysql_error());

and replace it with:
$sql = mysql_query("SELECT * FROM privates WHERE to = '$logged[username]' LIMIT ".$limits.",$max") or die(mysql_error());

and then I get the error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to = 'Dan' LIMIT 0,10' at line 1

But without the WHERE to . it works fine.

here is source:
<?php
include ("/home/jsfdan/public_html/config.php");




$max = 10; //amount of articles per page. change to what to want

$p = $_GET['p'];

if(empty($p))

{

$p = 1;

}

$limits = ($p - 1) * $max;

//view the news article!

if(isset($_GET['act']) && $_GET['act'] == "view")

{

$id = $_GET['id'];

$sql = mysql_query("SELECT * FROM privates'");

while($r = mysql_fetch_array($sql))

{

$id = $r['pid'];

$by = $r['from'];

$subject = $r['subject'];

echo "MID: $id --- $subject ---- By: $by<br><br>";

}



}else{



//view all the news articles in rows

$sql = mysql_query("SELECT * FROM privates WHERE to = '$logged[username]' LIMIT ".$limits.",$max") or die(mysql_error());

//the total rows in the table

$totalres = mysql_result(mysql_query("SELECT COUNT(pid) AS tot FROM privates"),0);

//the total number of pages (calculated result), math stuff...

$totalpages = ceil($totalres / $max);

//the table

echo "Hello $logged[username]<br><br>";

while($r = mysql_fetch_array($sql))

{

$id = $r['pid'];

$by = $r['from'];

$subject = $r['subject'];

echo "MID: $id --- $subject ---- By: $by<br><br>";

}

//close up the table

echo "</tr></table>";

for($i = 1; $i <= $totalpages; $i++){

//this is the pagination link

echo "<a href='w.php?p=$i'>$i</a>|";

}

}


?>

oesxyl
08-14-2008, 01:15 AM
$sql = mysql_query("SELECT * FROM privates WHERE 'to' = '".$logged['username']."' LIMIT ".$limits.",".$max) or die(mysql_error());
quoting problem and probably 'to' is mysql reserved word, check last I'm not sure and if is true change it to something else.

I check myself and 'to' is mysql reserved wordregards

UrbanTwitch
08-14-2008, 01:22 AM
So what do I do?

oesxyl
08-14-2008, 01:28 AM
So what do I do?
two solution:
- use 'to' instead of to in query
- change in table the column name field from 'to' to something else, 'user', 'to_user', whatever you want but not a mysql reserved word and then you can call it without apos, '

regards

UrbanTwitch
08-14-2008, 01:51 AM
Ok so I tried:


$sql = mysql_query("SELECT * FROM privates WHERE 'to' = ".$logged[username]." LIMIT ".$limits.",$max") or die(mysql_error());

And I get: Unknown column 'Dan' in 'where clause'

I am logged in as Dan. I thought it read the the coloum was 'to'.

EDIT: I tried:
$sql = mysql_query("SELECT * FROM privates WHERE 'to' = '$logged[username]' LIMIT ".$limits.",$max") or die(mysql_error()); and I get:

Hello Dan

1|2|3|4|5|6|7|8|9|

oesxyl
08-14-2008, 02:05 AM
I said in my replay that you have also incorect quoting. correct form is:

$sql = mysql_query("SELECT * FROM privates WHERE 'to' = '".$logged[username]."' LIMIT ".$limits.",".$max) or die(mysql_error());

this:

'to' = '$logged[username]' LIMIT
must be

'to' = '".$logged[username]."' LIMIT

and this:

LIMIT ".$limits.",$max"
must be:

LIMIT ".$limits.",".$max

regards

Mwnciau
08-14-2008, 02:09 AM
You need to use backticks for the to, not apostrophes:



$sql = mysql_query ( "SELECT * FROM `privates`
WHERE `to` = '" . $logged['username'] . "'
LIMIT " . $limits . ", " . $max . ";" )
or die ( mysql_error() );

UrbanTwitch
08-14-2008, 02:15 AM
Still getting

Hello Dan

1|2|3|4|5|6|7|8|9|

using
$sql = mysql_query ( "SELECT * FROM `privates` WHERE `to` = '".$logged[username]."' LIMIT ".$limits.",".$max." ")
or die ( mysql_error() );

I don't get it. It worked before without using WHERE `to`,etc.

oesxyl
08-14-2008, 02:33 AM
Still getting

Hello Dan

1|2|3|4|5|6|7|8|9|

using
$sql = mysql_query ( "SELECT * FROM `privates` WHERE `to` = '".$logged[username]."' LIMIT ".$limits.",".$max." ")
or die ( mysql_error() );

I don't get it. It worked before without using WHERE `to`,etc.
take it step by step and try to debug using echo/print_r/print at each step the results you get and don't get further until work.


if($sql){
while($row = mysql_fetch_assoc($sql)){
print_r($row);
}
}


and don't jump over checking. If you have mysql_query you must test the result, don't assume that work as is.

regards

oesxyl
08-14-2008, 02:36 AM
Still getting

Hello Dan

1|2|3|4|5|6|7|8|9|

using
$sql = mysql_query ( "SELECT * FROM `privates` WHERE `to` = '".$logged[username]."' LIMIT ".$limits.",".$max." ")
or die ( mysql_error() );

I don't get it. It worked before without using WHERE `to`,etc.
you have a error here:


while($r = mysql_fetch_array($sql)){ // <-- use mysql_fetch_assoc instead
$id = $r['pid']; // <-- because you use this
$by = $r['from'];
$subject = $r['subject'];
echo "MID: $id --- $subject ---- By: $by<br><br>";
}


regards

UrbanTwitch
08-14-2008, 02:42 AM
Ok so if I use this: It should show up [check for errors?]


<?php
include ("/home/jsfdan/public_html/config.php");
$max = 10; //amount of articles per page. change to what to want
$p = $_GET['p'];
if(empty($p))
{
$p = 10;
}
$limits = ($p - 1) * $max;
if(isset($_GET['act']) && $_GET['act'] == "view")
{
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM privates'");
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
echo "MID: $id --- $subject ---- By: $by<br><br>";
}

}else{

$sql = mysql_query ( "SELECT * FROM `privates` WHERE `to` = '".$logged[username]."' LIMIT ".$limits.",".$max." ")
or die ( mysql_error() );

$totalres = mysql_result(mysql_query("SELECT COUNT(pid) AS tot FROM privates"),0);

$totalpages = ceil($totalres / $max);

echo "Hello $logged[username]<br><br>";
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
echo "MID: $id --- $subject ---- By: $by<br><br>";
}
echo "</tr></table>";
for($i = 1; $i <= $totalpages; $i++){
echo "<a href='w.php?p=$i'>$i</a>|";
}
}
?>

oesxyl
08-14-2008, 02:52 AM
<?php
include ("/home/jsfdan/public_html/config.php");
$max = 10; //amount of articles per page. change to what to want
$p = $_GET['p'];
if(empty($p)){
$p = 10;
}
$limits = ($p - 1) * $max;
if(isset($_GET['act']) && $_GET['act'] == "view"){
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM privates'");
if($sql){ // <-- checking
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
echo "MID: $id --- $subject ---- By: $by<br><br>";
}
}else{
// error $sql
}
}else{
$sql = mysql_query ( "SELECT * FROM `privates` WHERE `to` = '".$logged[username]."' LIMIT ".$limits.",".$max." ")
or die ( mysql_error() );
// not sure if that work, expand and write checking
// $totalres = mysql_result(mysql_query("SELECT COUNT(pid) AS tot FROM privates"),0);
$q = "SELECT COUNT(pid) AS tot FROM privates";
$qres = mysql_query($q);
if($qres){
$totalres = mysql_result($qres,0,0);
}else{
// error $qres
}
// you are sure that $max can't be 0, $totalres have any value assigned?
$totalpages = ceil($totalres / $max);
echo "Hello $logged[username]<br><br>";
// missing checking of $sql here, you must add
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
echo "MID: $id --- $subject ---- By: $by<br><br>";
}
echo "</tr></table>";
for($i = 1; $i <= $totalpages; $i++){
// not a error I guess, but could generate problem, I suggest:
// echo '<a href="w.php?p='.$i.'">'.$i.'</a>|';
echo "<a href='w.php?p=$i'>$i</a>|";
}
}
?>

I think it work, not sure, but read the comments please.

regards

UrbanTwitch
08-14-2008, 03:21 AM
Nope. :\ What do I do with this:
$totalres = mysql_result(mysql_query("SELECT COUNT(pid) AS tot FROM privates"),0);

My updated code:


<?php
include ("/home/jsfdan/public_html/config.php");
$max = 10; //amount of articles per page. change to what to want
$p = $_GET['p'];
if(empty($p)){
$p = 10;
}
$limits = ($p - 1) * $max;
if(isset($_GET['act']) && $_GET['act'] == "view"){
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM privates'");
if($sql){ // <-- checking
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
echo "MID: $id --- $subject ---- By: $by<br><br>";
}
}else{
// error $sql
}
}else{
$sql = mysql_query ( "SELECT * FROM `privates` WHERE `to` = '".$logged[username]."' LIMIT ".$limits.",".$max." ")
or die ( mysql_error() );


$q = "SELECT COUNT(pid) AS tot FROM privates";
$qres = mysql_query($q);
if($qres){
$totalres = mysql_result($qres,0,0);
}else{
// error $qres
}
// you are sure that $max can't be 0, $totalres have any value assigned?
$totalpages = ceil($totalres / $max);
echo "Hello $logged[username]<br><br>";
if($sql){ // <-- checking
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
echo "MID: $id --- $subject ---- By: $by<br><br>";
}
echo "</tr></table>";
for($i = 1; $i <= $totalpages; $i++){


echo "<a href=w.php?p=$i>$i</a>|";
}
}
}
?>

oesxyl
08-14-2008, 03:40 AM
Nope. :\ What do I do with this:
$totalres = mysql_result(mysql_query("SELECT COUNT(pid) AS tot FROM privates"),0);
remove it, is replaced by 3 lines $q = ...; $qres = ....; ...

where I put // error XXX, put some code for debug
for example to // error $qres, put echo '<pre>'.mysql_error().'</pre>';



My updated code:


<?php
include ("/home/jsfdan/public_html/config.php");
$max = 10; //amount of articles per page. change to what to want
$p = $_GET['p'];
if(empty($p)){
$p = 10;
}
$limits = ($p - 1) * $max;
if(isset($_GET['act']) && $_GET['act'] == "view"){
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM privates'");
if($sql){ // <-- checking
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
echo "MID: $id --- $subject ---- By: $by<br><br>";
}
}else{
// error $sql, added
echo '<pre>'.mysql_error().'</pre>';
}
}else{
$sql = mysql_query ( "SELECT * FROM `privates` WHERE `to` = '".$logged[username]."' LIMIT ".$limits.",".$max." ")
or die ( mysql_error() );


$q = "SELECT COUNT(pid) AS tot FROM privates";
$qres = mysql_query($q);
if($qres){
$totalres = mysql_result($qres,0,0);
}else{
// error $qres
echo '<pre>'.mysql_error().'</pre>';
}
// you are sure that $max can't be 0, $totalres have any value assigned?
$totalpages = ceil($totalres / $max);
echo "Hello $logged[username]<br><br>";
if($sql){ // <-- checking
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
echo "MID: $id --- $subject ---- By: $by<br><br>";
}
echo "</tr></table>";
for($i = 1; $i <= $totalpages; $i++){


echo "<a href=w.php?p=$i>$i</a>|";
}
}
}
?>

also try to print/echo or print_r from top to bottom variables to see what values have and if are what you want.

regards

UrbanTwitch
08-14-2008, 05:38 AM
I tried print but no go. Whats print_r do and how do I do it for my page?

oesxyl
08-14-2008, 05:45 AM
I tried print but no go. Whats print_r do and how do I do it for my page?
echo/print don't work with arrays. To print arrays, can use print_r or var_dump:

http://www.php.net/manual/en/function.print-r.php

php manual is a good resource. keep it handy, :)

regards

UrbanTwitch
08-14-2008, 06:43 AM
I don't mean to be a burden but if you are really good with print_r, could you do it for me? I will learn of it.

If not, I will go ahead and attempt it. By that I mean put print_r into the pagination.

oesxyl
08-14-2008, 06:56 AM
I don't mean to be a burden but if you are really good with print_r, could you do it for me? I will learn of it.

If not, I will go ahead and attempt it. By that I mean put print_r into the pagination.
please:
- post the code you have now
- explain what's wrong, the page is still blank or what?
- explain what's wrong with print_r

I said to use print_r for debuging of your code, not pagination. Something like this:


$a = array("a", "b", "c");
print_r($a);
regards

UrbanTwitch
08-14-2008, 07:33 AM
You mean like this:
<?php
include ("/home/jsfdan/public_html/config.php");
$max = 10; //amount of articles per page. change to what to want
$p = $_GET['p'];
if(empty($p)){
$p = 10;
}
$limits = ($p - 1) * $max;
if(isset($_GET['act']) && $_GET['act'] == "view"){
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM privates'");
if($sql){ // <-- checking
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
print "MID: $id --- $subject ---- By: $by<br><br>";
}
}else{
// error $sql
}
}else{
$sql = mysql_query ( "SELECT * FROM `privates` WHERE `to` = '".$logged[username]."' LIMIT ".$limits.",".$max." ")
or die ( mysql_error() );


$q = "SELECT COUNT(pid) AS tot FROM privates";
$qres = mysql_query($q);
if($qres){
$totalres = mysql_result($qres,0,0);
}else{
// error $qres
}
// you are sure that $max can't be 0, $totalres have any value assigned?
$totalpages = ceil($totalres / $max);
print "Hello $logged[username]<br><br>";
if($sql){ // <-- checking
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
$a = array("$id", "$subject", "$by");
print_r($a);
}
print "</tr></table>";
for($i = 1; $i <= $totalpages; $i++){


print "<a href=w.php?p=$i>$i</a>|";
}
}
}
?>

Edit: tried it... nope :\

oesxyl
08-14-2008, 07:51 AM
Take the code from here. I can't test it because I don't have your database setup and others thing you have so post what's wrong.


<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
include ("/home/jsfdan/public_html/config.php");
$max = 10; //amount of articles per page. change to what to want
$p = $_GET['p'];
if(empty($p)){
$p = 10;
}
echo 'p: '.$p.'<br/>'; // add this and remove it if $p value is ok
$limits = ($p - 1) * $max;
echo 'limits: '.$limits.'<br/>'; // add this and remove it if $p value is ok
if(isset($_GET['act']) && $_GET['act'] == "view"){
echo 'act and view branch<br/>';
$id = $_GET['id'];
echo 'id: '.$id.'<br/>'; // add this and remove it if $p value is ok
$sql = mysql_query("SELECT * FROM privates'");
if($sql){ // <-- checking
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
print "MID: $id --- $subject ---- By: $by<br><br>";
}
}else{
// error $sql
print '<pre>'.mysql_error().'</pre>';
}
}else{
echo 'act and view else branch<br/>';
$sql = mysql_query ( "SELECT * FROM `privates` WHERE `to` = '".$logged[username]."' LIMIT ".$limits.",".$max." ")
or die ( mysql_error() );

$q = "SELECT COUNT(pid) AS tot FROM privates";
$qres = mysql_query($q);
if($qres){
$totalres = mysql_result($qres,0,0);
}else{
// error $qres
print '<pre>'.mysql_error().'</pre>';
}
// you are sure that $max can't be 0, $totalres have any value assigned?
$totalpages = ceil($totalres / $max);
print "Hello $logged[username]<br><br>";
if($sql){ // <-- checking
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
}
print "</tr></table>";
for($i = 1; $i <= $totalpages; $i++){
print "<a href=w.php?p=$i>$i</a>|";
}
}
}
?>

this was an example of how you can use print_r to find what is the value of $a, have absolutely no connection with your script.


$a = array("$id", "$subject", "$by");
print_r($a);

sorry, I don't see $id, $subject and $by in your $a.
this part of the code could be replaced by:

print_r($r); because $r is already a array and contain the values you want to see.

regards

UrbanTwitch
08-14-2008, 08:56 AM
I get:


Notice: Undefined index: p in /home/jsfdan/public_html/w.php on line 6
p: 10
limits: 90
act and view else branch

Notice: Use of undefined constant username - assumed 'username' in /home/jsfdan/public_html/w.php on line 31

Using the script you gave me.

oesxyl
08-14-2008, 09:11 AM
I get:


Notice: Undefined index: p in /home/jsfdan/public_html/w.php on line 6
p: 10
limits: 90
act and view else branch

Notice: Use of undefined constant username - assumed 'username' in /home/jsfdan/public_html/w.php on line 31

Using the script you gave me.
ok, that's good, we know now whats wrong.
1. you don't pass parameter 'p' from the page who call this script that is line 6.


$p = $_GET['p'];

2. username is not quoted

see the changes in code, have 2 comments where I change:

[QUOTE=oesxyl;723399]Take the code from here. I can't test it because I don't have your database setup and others thing you have so post what's wrong.


<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
include ("/home/jsfdan/public_html/config.php");
$max = 10; //amount of articles per page. change to what to want
// I changed next 3 lines:
$p = 10;
if(!empty($_GET['p'])){
$p = 10;
}
echo 'p: '.$p.'<br/>'; // add this and remove it if $p value is ok
$limits = ($p - 1) * $max;
echo 'limits: '.$limits.'<br/>'; // add this and remove it if $p value is ok
if(isset($_GET['act']) && $_GET['act'] == "view"){
echo 'act and view branch<br/>';
$id = $_GET['id'];
echo 'id: '.$id.'<br/>'; // add this and remove it if $p value is ok
$sql = mysql_query("SELECT * FROM privates'");
if($sql){ // <-- checking
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
print "MID: $id --- $subject ---- By: $by<br><br>";
}
}else{
// error $sql
print '<pre>'.mysql_error().'</pre>';
}
}else{
echo 'act and view else branch<br/>';
// I change this too, instead of $logged[username] I put $logged['username']
$sql = mysql_query ( "SELECT * FROM `privates` WHERE `to` = '".$logged['username']."' LIMIT ".$limits.",".$max." ")
or die ( mysql_error() );

$q = "SELECT COUNT(pid) AS tot FROM privates";
$qres = mysql_query($q);
if($qres){
$totalres = mysql_result($qres,0,0);
}else{
// error $qres
print '<pre>'.mysql_error().'</pre>';
}
// you are sure that $max can't be 0, $totalres have any value assigned?
$totalpages = ceil($totalres / $max);
print "Hello $logged[username]<br><br>";
if($sql){ // <-- checking
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
}
print "</tr></table>";
for($i = 1; $i <= $totalpages; $i++){
print "<a href=w.php?p=$i>$i</a>|";
}
}
}
?>

how you call this script, who call him and how? How you pass data, I mean 'p' and from where this $logged array come?

regards

UrbanTwitch
08-14-2008, 09:22 AM
This is a PM inbox pagination. $logged comes from config.php which is what you used to state the person who is logged ins info like $logged[age] - your age. etc. OK so I ran your code and I get:

p: 10
limits: 90
act and view else branch
Hello Dan

1|2|3|4|5|6|7|8|9|

But no errors. Just that. ^^

oesxyl
08-14-2008, 10:46 AM
This is a PM inbox pagination. $logged comes from config.php which is what you used to state the person who is logged ins info like $logged[age] - your age. etc. OK so I ran your code and I get:

p: 10
limits: 90
act and view else branch
Hello Dan

1|2|3|4|5|6|7|8|9|

But no errors. Just that. ^^
I add 3 lines, change the script and check again:


<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
include ("/home/jsfdan/public_html/config.php");
$max = 10; //amount of articles per page. change to what to want
// I changed next 3 lines:
$p = 10;
if(!empty($_GET['p'])){
$p = 10;
}
echo 'p: '.$p.'<br/>'; // add this and remove it if $p value is ok
$limits = 0; // <-- change this
print_r($logged); <--
print_r($_GET); <--
// $limits = ($p - 1) * $max;
echo 'limits: '.$limits.'<br/>'; // add this and remove it if $p value is ok
if(isset($_GET['act']) && $_GET['act'] == "view"){
echo 'act and view branch<br/>';
$id = $_GET['id'];
echo 'id: '.$id.'<br/>'; // add this and remove it if $p value is ok
$sql = mysql_query("SELECT * FROM privates'");
if($sql){ // <-- checking
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
print "MID: $id --- $subject ---- By: $by<br><br>";
}
}else{
// error $sql
print '<pre>'.mysql_error().'</pre>';
}
}else{
echo 'act and view else branch<br/>';
// I change this too, instead of $logged[username] I put $logged['username']
$sql = mysql_query ( "SELECT * FROM `privates` WHERE `to` = '".$logged['username']."' LIMIT ".$limits.",".$max." ")
or die ( mysql_error() );

$q = "SELECT COUNT(pid) AS tot FROM privates";
$qres = mysql_query($q);
if($qres){
$totalres = mysql_result($qres,0,0);
}else{
// error $qres
print '<pre>'.mysql_error().'</pre>';
}
// you are sure that $max can't be 0, $totalres have any value assigned?
$totalpages = ceil($totalres / $max);
print "Hello $logged[username]<br><br>";
if($sql){ // <-- checking
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
}
print "</tr></table>";
for($i = 1; $i <= $totalpages; $i++){
print "<a href=w.php?p=$i>$i</a>|";
}
}
}
?>

regards

UrbanTwitch
08-14-2008, 05:15 PM
EH, I get:

p: 10

act and view else branch
Hello Dan

1|2|3|4|5|6|7|8|

Umm, where are arrays coming from?

oesxyl
08-14-2008, 05:23 PM
EH, I get:

p: 10
Array ( [p] => 1 ) limits: 5
act and view else branch
Hello Dan

1|2|3|4|5|6|7|8|

Umm, where are arrays coming from?
edit your post and remove that array, is not safe to post this. Is enought to know that exists.
This is the content of $logged array from your config

sorry, I must take a break, but I will come back and continue
regards

hinch
08-14-2008, 05:26 PM
passwords are encrypted at least :)

UrbanTwitch
08-14-2008, 05:28 PM
Alright so now I have it like this:


<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
include ("/home/jsfdan/public_html/config.php");
$max = 10; //amount of articles per page. change to what to want
// I changed next 3 lines:
$p = 10;
if(!empty($_GET['p'])){
$p = 10;
}
$limits = 5; //

if(isset($_GET['act']) && $_GET['act'] == "view"){
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM privates'");
if($sql){ // <-- checking
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
print "MID: $id --- $subject ---- By: $by<br><br>";
}
}else{
// error $sql
print '<pre>'.mysql_error().'</pre>';
}
}else{
echo 'act and view else branch<br/>';
// I change this too, instead of $logged[username] I put $logged['username']
$sql = mysql_query ( "SELECT * FROM `privates` WHERE `to` = '".$logged['username']."' LIMIT ".$limits.",".$max." ")
or die ( mysql_error() );

$q = "SELECT COUNT(pid) AS tot FROM privates";
$qres = mysql_query($q);
if($qres){
$totalres = mysql_result($qres,0,0);
}else{
// error $qres
print '<pre>'.mysql_error().'</pre>';
}
// you are sure that $max can't be 0, $totalres have any value assigned?
$totalpages = ceil($totalres / $max);
print "Hello $logged[username]<br><br>";
if($sql){ // <-- checking
while($r = mysql_fetch_assoc($sql)){
$id = $r['pid'];
$by = $r['from'];
$subject = $r['subject'];
}
print "</tr></table>";
for($i = 1; $i <= $totalpages; $i++){
print "<a href=w.php?p=$i>$i</a>|";
}
}
}
?>

What do I do now? Input like the info like $title, $from, etc.?

UrbanTwitch
08-14-2008, 10:10 PM
http://i33.tinypic.com/2ltj2xe.png

Thank you everyone! :-)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum