Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Help
Search
Adult Filter
Calendar
Chatroom
Login
Register
Furtopia | Family Friendly Furry Forum and IRC Chat!
»
Furtopia services and support
»
furtopia.org services support
»
Serious PHP problem (with MySQL)
« previous
next »
Print
Pages: [
1
]
Author
Topic: Serious PHP problem (with MySQL) (Read 1345 times)
0 Members and 1 Guest are viewing this topic.
Mister Initial Man
Sr. Member
Species: Lynx/Bear
Posts: 401
Serious PHP problem (with MySQL)
«
on:
December 02, 2005, 12:53:01 pm »
One of my pages reads like this:
Code Sample
<?php
include('../../inserts/head.htm');
echo('<link type="text/css" rel="stylesheet" href="../../setup.css">');
$dbhost = 'localhost';
$dbuser = 'username';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'coachrandom';
mysql_select_db($dbname);
$cid = (!empty($_GET['comic'])&&is_numeric($_GET['comic']))?$_GET['comic']:0;
$query = @mysql_query('SELECT * FROM `coachrandom` WHERE `Number` = '.$cid.' LIMIT 1');
while($row=@mysql_fetch_object($query))
{
$prev = (($row->Number-1)>=0)?($row->Number-1):-1;
$qr=@mysql_result(@mysql_query('SELECT `NUMBER` FROM `coachrandom` WHERE `NUMBER`= '.($cid+1).' LIMIT 1'), 0);
$next = (!empty($qr))?$qr:-1;
$last=@mysql_result(@mysql_query('SELECT `Number` FROM `coachrandom` ORDER BY `Number` DESC LIMIT 1'), 0);
echo '<title>'.$row->Title.'</title>';
echo '</head> <body>';
echo '<h2>Coach Random # '.$row->Number.'</h2>';
echo '<h1>'.$row->Title.'</h1>';
if($row->date_select==1)
{
echo '<h3>'.$row->alt_date.'</h3>';
}
elseif($row->date_select==2)
{
echo '<h3>'.$row->Weekday.', '.$row->Month.' '.$row->Day.', '.$row->Year.'</h3>';
}
if(!empty($row->Notes))
{
echo '<h4>'.$row->Notes.'</h4>';
}
if(!empty($row->Comics))
{
echo '<p><img src="./comics/'.$row->Semester.'/'.$row->Comic.'" alt="Comic"></p>';
}
echo '<p><strong class="commentator">Drawn:</strong> '.$row->Drawn.'</p>';
echo $row->Commentary;
if(!empty($row->Links)&&$row->Cavalier_Daily!=0)
{
echo '<ul>';
if($row->Cavalier_Daily!=0)
{echo '<li><a href=" http://www.cavalierdaily.com/home.asp?pid='.$row->CavDaily_Edition.'">Cavalier Daily, '.$row->Month.' '.$row->Day.', '.$row->Year.'.</a></li>'; }
if(!empty($row->Links))
{echo $row->Links;}
echo '</ul>';
}
echo '<ul>';
echo '<li><a href="' '">First</a></li>';
echo '<li><a href="?comic=0">First</a></li>';
echo ($prev>=0)?' <li><a href="?comic='.$prev.'">Back</a></li> ':'';
echo '<li><a href="URL">Back to Main</a></li>';
echo '<li><a href="URL">Back to Chronology</a></li>';
echo ($next>=0)?' <li><a href="?comic='.$next.'">Next</a></li> ':'';
echo '<li><a href="?comic='.$last.'">Last</a></li>';
echo '</ul>';
}
mysql_free_result($query);
mysql_close($conn);
?>
</body>
</html>
The URL is
http://coachrandom.furtopia.org/chronology/comics/comics.php
As you can see, I have an insert which contains my Doctype and my head, as well as some PHP for a database.
When I go to the page, it's completely blank, and the source looks like this:
Code Sample
<html><body></body></html>
I don't even get my link to my CSS page shown in the source, and it's echoed! Even if my password was wrong (and I checked carefully to make sure it wasn't), I should at least see that echo.
Where in tarnation did I go wrong?!
Logged
The Lynx's Den
Serra Belvoule
Hero Member
Holder of the Cookie Jar!
Posts: 17006
Serious PHP problem (with MySQL)
«
Reply #1 on:
December 02, 2005, 01:01:54 pm »
Recheck that, it is not complete I think
'>
Logged
I ate a bag of grapes and now I own the world.
Mister Initial Man
Sr. Member
Species: Lynx/Bear
Posts: 401
Serious PHP problem (with MySQL)
«
Reply #2 on:
December 02, 2005, 02:13:44 pm »
What am I missing? I'm not good at PHP. so I had to go on someone else's advice.
Logged
The Lynx's Den
Nocte
Hero Member
Posts: 1689
Serious PHP problem (with MySQL)
«
Reply #3 on:
December 02, 2005, 03:32:43 pm »
The problem lies near the end:
Code Sample
echo '<li><a href="' '">First</a></li>';
The apostrophes inside the href attribute have to be escaped, otherwise it will mark the end of the string that will be echoed. It'll probably work if you change it to:
Code Sample
echo '<li><a href="\' \'">First</a></li>';
Logged
Drawing tutorial
Avatar information
FEHu3a A+ C D-- H M- P R++ T W-- Z Sm- RLCT a cl++++ d+ e+++ f- h+++ i++ j p sm*
Mister Initial Man
Sr. Member
Species: Lynx/Bear
Posts: 401
Serious PHP problem (with MySQL)
«
Reply #4 on:
December 02, 2005, 04:10:37 pm »
Hmmm... I'll change that. That bit shouldn't be in there at all.
EDIT: It's a start, anyways. This is what I see when I look at my source:
Code Sample
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="content-script-type" content="text/javascript">
<meta name="Content-Style-Type" content="text/css">
<meta name="Author" content="John-David Kraaikamp, Scott Ruhl">
<meta name="Description" content="Coach Random">
<meta name="Keywords" content="Coach, Random, Comic, Furry, Funnies, Dogs, Beer, College, Cavalier, Daily"><link type="text/css" rel="stylesheet" href="../../setup.css"></body>
</html>
In other words, something is wrong between "while($row=@mysql_fetch_object($query))" and mysql_close($conn);
Logged
The Lynx's Den
Print
Pages: [
1
]
« previous
next »
Furtopia | Family Friendly Furry Forum and IRC Chat!
»
Furtopia services and support
»
furtopia.org services support
»
Serious PHP problem (with MySQL)