Old 12-30-2005   #1 (permalink)
Registered User
 
Join Date: Dec 2005
Posts: 1

Prob getting Scrowler's PHP tutorial working.

Hi,
I'm trying to adapt Scrowler's "Limiting MySQL Query Results (With Pagination)" to my website.

I keep getting this error:

Parse error: parse error, unexpected ':' in /xxx/xxx/xxx/xxx/mypage.php on line 40

This is the portion of the code the error message is referring to:

PHP Code:
if($_GET[&#8216;page’] < 0){
header(&#8220;Location: index.php?page=0&limit=”.$limit);

I copy/pasted the entire script and added it to my website.

The only things I changed were substituting the OurTable" with the name of my table and "OurData" with the column name from my table, which has the text I want to display, but limited. I also added my Server and DB connect code.

I'm not sure why the start variable would ever be negative. When would that ever happen?

Actually all I wanted to do is just limit the length of the text so I tried to comment that code that gave me the error and try the script without it. I ended up with another error further down, so I gave up and put it back in.

I've only been learning PHP for a short while so I probably did something dumb, I've spent a couple hours going over this and can't figure it out.

I don't know what is in the include config.php file, I made some assumptions and I don't have a problem connecting to my database.

I have a terrible work-around in place at the moment. I placed my overly long paragraphs in 25px x 400px html paragraphs with a CSS overflow value of "hidden". Only the first line of each paragraph is displayed. I'd really like to do this correctly!

Here is the page:


PHP Code:
<html>
<head>
<title>test page</title>
</head>
<body>

<?php
$sql_host     
'localhost';
$sql_username ' MyUserName';
$sql_password ' MyPassword ';
$sql_database ' MyDB ';

$dbcnx = @mysql_connect($sql_host,$sql_username,$sql_password);
if (!
$dbcnx) {
  exit(
'<p>Unable to connect to the ' .
      
'database server at this time.</p>');
}
if (!@
mysql_select_db($sql_database)) {
  exit(
'<p>Unable to locate the database at this time.</p>');
}

if ( 
$_GET[&#8216;number’] == NULL ){
$limit 10;
} else {
$limit $_GET[&#8216;number’];
}

if (
$_GET[&#8216;page’]==NULL){
$start 0;
} else {
$start $_GET[&#8216;page’];
}

// the if above, states that if the variable in the URL named page has a value, $start will be set to it, otherwise by default it is set to 0, meaning that it will start at the beginning of the table by default.

if($_GET[&#8216;page’] < 0){
header(&#8220;Location: index.php?page=0&limit=”.$limit);
}

// this if above checks that the start variable isn’t negative, because if it is, our script will screw up. If it finds that it is, it redirects to the default page where the start is 0.

$query mysql_query(&#8220;SELECT * FROM joke LIMIT ‘$start’, ‘$limit’”) or die(mysql_error());

// the query above now has the [a] and [b] operators incorporated, making our script paginated. All we need to do now is add the next and previous links.

while ($row mysql_fetch_array ($query) ) {
echo &
#8216;<p>’.$row[‘joketext’].’</p>’;
}

$previous $start $limit;
$next $start $limit;
echo 
'<a href="index.php?start='.$previous.'">Previous Page</a> - ';
echo 
'<a href="index.php?start='.$next.'">Next Page</a>';

// the set of statements above displays the previous and next page links
?>
</body>
</html>

Last edited by racerfrank; 12-31-2005 at 05:48 AM.
racerfrank is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-31-2005   #2 (permalink)
Invicible Snake
 
ParaSnake's Avatar
 
Join Date: Sep 2004
Location: Ho Chi Minh City,Vietnam
Posts: 668

Send a message via MSN to ParaSnake Send a message via Yahoo to ParaSnake
the quote " has been replaced by ‘ and “ , i think its the problem.
If not,try to use $_GET[page] instead of $_GET['page']; ,i sometimes got that problem
__________________
ParaSnake is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 01-18-2006   #3 (permalink)
code anyone?
 
scrowler's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Posts: 590

Send a message via MSN to scrowler Send a message via Skype™ to scrowler
don't cut and paste, that's the problem!
__________________
BioRUST Tutorials - the birthplace
scrowler is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Tutorial Trio! Man1c M0g Announcements 3 07-09-2005 09:15 AM
My blender&yafray HDRI tutorial Milkdrop Blender 3D 14 09-01-2004 06:33 PM
PHP Tutorial Requests Man1c M0g BioRUST Specific Threads 6 06-17-2004 09:16 PM


All times are GMT +1. The time now is 08:20 AM.
Content Relevant URLs by vBSEO 3.2.0

Design & Content © BioRUST 2008 :: PRIVACY STATEMENT :: LEGAL INFORMATION :: ADVERTISING MEDIA KIT