|
|
| Welcome to the Mac Forums forums. Please read the FAQ if you have questions. Register to participate. |
|
|||||||
| TouchArcade.com - iPhone Game Reviews and News |
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
macrumors 65816
Join Date: Jan 2006
Location: Scotlands
|
little SQL help please
hiya im working on my test development http://test.jennifersplaygroup.co.uk now if you go to my stories page then click on any story and then on a comment it comes up a error
Code:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/fhlinux169/t/test.jennifersplaygroup.co.uk/user/htdocs/includes/story_comments.php on line 23 I been looking though the code but can't seem to be able to find the error Code:
<?php
$host = "mysql10.streamline.net";
$username = "usr";
$password = "pass";
$database = "database";
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
$server = mysql_connect($host, $username, $password);
$db = mysql_select_db($database, $server);
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM `storys_comments` WHERE story_id = $id ORDER BY id DESC");
?>
<div id="globalNav">
<div>
<h2>Comments</h2>
</div>
</div>
<div id="headlines">
</div>
<div id="content">
<div>
<?php
while ($row = mysql_fetch_array($sql, MYSQL_BOTH)) {
print nl2br($row[3]);
print "<br />By $row[2]<br /><hr><br />";
}
?>
</div>
</div>
<!-- end content -->
<div id="navBar">
|
|
|
|
| babyjenniferLB |
| View Public Profile |
| Find More Posts by babyjenniferLB |
|
|
#2 | ||
|
macrumors 68020
Join Date: Nov 2003
|
Quote:
Should be something along the lines of, where fieldname is a name of the field in the table you want the info organised by: Quote:
PS: I take it you got it working because I can see no error anymore.
__________________
Snow Leopard is animated |
||
|
|
|
|
|
#3 | |
|
Thread Starter
macrumors 65816
Join Date: Jan 2006
Location: Scotlands
|
Quote:
Code:
<?php
while ($row = mysql_fetch_array($sql, MYSQL_BOTH)) {
print nl2br($row[3]);
print "<br />By $row[2]<br /><hr><br />";
}
?>
|
|
|
|
|
| babyjenniferLB |
| View Public Profile |
| Find More Posts by babyjenniferLB |
|
|
#4 |
|
macrumors regular
Join Date: Apr 2003
|
don't put quotes around storys_comments
|
|
|
|
| Thom_Edwards |
| View Public Profile |
| Find More Posts by Thom_Edwards |
|
|
#5 |
|
Thread Starter
macrumors 65816
Join Date: Jan 2006
Location: Scotlands
|
|
|
|
|
| babyjenniferLB |
| View Public Profile |
| Find More Posts by babyjenniferLB |
|
|
#6 |
|
macrumors member
Join Date: Oct 2006
Location: earth
|
I noticed you connected to the server twice:
PHP Code:
Anyway, looks like the error is down here: PHP Code:
PHP Code:
See if it fixes the problem. -stndn. |
|
|
|
|
|
#7 |
|
macrumors 65816
Join Date: Sep 2006
Location: Tiger Mountain - WA State
|
I can give you the VB equivalent code that will work:
Yours: "SELECT * FROM `storys_comments` WHERE story_id = $id ORDER BY id DESC" VB: "SELECT * FROM storys_comments WHERE story_id = " & id & " ORDER BY id DESC" Not sure if your variable is ID, and the leading "$" means to concatenate. If so, you might just need to also concatenate your "ORDER BY" clause as well. You are passing this as a literal, correct?
__________________
The more you can increase fear of drugs and crime, welfare mothers, immigrants and aliens, the more you control all the people. - Noam Chomsky |
|
|
|
|
|
#8 | |
|
Thread Starter
macrumors 65816
Join Date: Jan 2006
Location: Scotlands
|
Quote:
|
|
|
|
|
| babyjenniferLB |
| View Public Profile |
| Find More Posts by babyjenniferLB |
|
|
#9 | |
|
macrumors Demi-Goddess
|
Quote:
PHP Code:
__________________
15" MacBook Pro | black (iPhone 3GS|MacBook) | intel Mac mini | athlon64 x2 4800+ + gentoo linux, windows server 2008
moof! |
|
|
|
|
|
|
#10 |
|
macrumors member
Join Date: Oct 2006
Location: earth
|
Oopss... sorry
I didn't know the php tag won't parse the [ b ] to bold. It's left as is, that's why you got the parse error there.. What I really meant was: while ($row = mysql_fetch_array ($sql, $connection)) { Try it again and see if it works.. -stndn. |
|
|
|
|
|
#11 | |
|
Thread Starter
macrumors 65816
Join Date: Jan 2006
Location: Scotlands
|
Quote:
Code:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/fhlinux169/t/test.jennifersplaygroup.co.uk/user/htdocs/includes/story_comments.php on line 12 Code:
<?php
$host = "mysql10.streamline.net";
$username = "usr";
$password = "pass";
$database = "db";
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
$server = mysql_connect($host, $username, $password);
$db = mysql_select_db($database, $server);
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM storys_comments WHERE story_id = $id ORDER BY id DESC");
while ($row = mysql_fetch_array ($sql, $connection)) {
print nl2br($row[3]);
print "<br />By $row[2]<br /><hr><br />";
}
?>
Last edited by Mitthrawnuruodo : Jun 6, 2007 at 05:26 AM. Reason: Removed username, password and database |
|
|
|
|
| babyjenniferLB |
| View Public Profile |
| Find More Posts by babyjenniferLB |
|
|
#12 |
|
macrumors Demi-Goddess
|
You know, I don't think it was much about solving your problem as it was fixing another potentially larger problem, cause I think that person was pointing out the possibility of SQL injection.
Try removing $connection from the mysql_fetch_array. Also, edit your post, you just left in your password and username
__________________
15" MacBook Pro | black (iPhone 3GS|MacBook) | intel Mac mini | athlon64 x2 4800+ + gentoo linux, windows server 2008
moof! |
|
|
|
|
|
#13 |
|
macrumors member
Join Date: Oct 2006
Location: earth
|
Ouch, what was I thinking?
Let's look at it again, one at a time. But before we do that, please remove your login/password details and just put an example or whatever in your code. Going down to the line which gave us the problems, the original code was: while ($row = mysql_fetch_array($sql, MYSQL_BOTH)) { Which gave us troubles because MYSQL_BOTH is not a connection link to database. My original suggestion was to change it to this: while ($row = mysql_fetch_array ($sql, $connection)) { But that didn't work also, because I made a mistake by mixing the call to mysql_query (which takes an optional link to database, in which case would be $server if you wanted to include that) and the call to mysql_fetch_array (which takes an optional second parameter which is the result type). Try what's suggested by janey and simply remove the second parameter from the code, making it: PHP Code:
Now, let's move back to the top for a bit (although it's not that related to your original problem): PHP Code:
Now, we get $server as a link to database, and $db (and $connection) as the result from changing database to use. Now that I've looked into the PHP manual again, it looks like MYSQL_BOTH is supposedly pre-defined by PHP to mean return both associative and numeric array. However, I'm not sure why this doesn't work in your case. My guess is that there's an error on the call to mysql_query () itself, which caused no results to be returned. But then again, I'm not sure after I've made two silly mistakes in a row... -( If my guess is correct, probably the column 'id' is not defined in database? Would you give this a try? Change this line: $sql = mysql_query("SELECT * FROM storys_comments WHERE story_id = $id ORDER BY id DESC"); To this line: $sql = mysql_query("SELECT * FROM storys_comments WHERE story_id = $id ORDER BY story_id DESC"); Of course, if the column id is actually defined, just ignore this. -stndn. |
|
|
|
|
|
#14 | |
|
Thread Starter
macrumors 65816
Join Date: Jan 2006
Location: Scotlands
|
Quote:
|
|
|
|
|
| babyjenniferLB |
| View Public Profile |
| Find More Posts by babyjenniferLB |
|
|
#15 |
|
Thread Starter
macrumors 65816
Join Date: Jan 2006
Location: Scotlands
|
ok no more errors but its also not doing what it is supposed to do anymore it is uploading the comments but its not saving the story id number with the comment and its not displaying the comments and i think its using frames someware
here are the sources to the files newcomment.php Code:
<?php print "<IFRAME SRC=\"includes/storys_comment.php?id=".$_GET['id']."\" width=\"100%\" height=\"275\" frameborder=\"0\" name=\"bottomiframe\"></IFRAME>"; ?> Code:
<?php
$host = "mysql10.streamline.net";
$username = "usr";
$password = "pass";
$database = "db";
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
$server = mysql_connect($host, $username, $password);
$db = mysql_select_db(jennifersp, $server);
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM `storys` WHERE id = $id");
$row = mysql_fetch_row($sql);
?>
<div>
<?php
print "<A HREF=\"javascript:popUp('./story_comment_whole.php?id=".$id."')\">Comments</A>"; ?>
</div>
<?php
print "<b>$row[1]</b> by $row[2]<br><br>";
print nl2br($row[3]);
?>
<br /><br />
<a href="http://jennifersplaygroup.co.uk/?q=node/11">Back to the story page</a>
</div>
Code:
<?php
print "<IFRAME SRC=\"includes/story_comments.php?id=".$_GET['id']."\" width=\"100%\" height=\"325\" frameborder=\"0\" name=\"topiframe\"></IFRAME><br />";
?>
<br />
<a href="javascript:ajaxpage('includes/newcomment.php', 'addnew');">Add new comment</a>
<div id="addnew">
</div>
Code:
<?php
$host = "mysql10.streamline.net";
$username = "usr";
$password = "pass";
$database = "db";
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
$server = mysql_connect($host, $username, $password);
$db = mysql_select_db($database, $server);
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM storys_comments WHERE story_id = $id ORDER BY id DESC");
while ($row = mysql_fetch_array ($sql)) {
print nl2br($row[3]);
print "<br />By $row[2]<br /><hr><br />";
}
?>
Code:
<?php
$host = "mysql10.streamline.net";
$username = "us";
$password = "paass";
$database = "db";
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
$server = mysql_connect($host, $username, $password);
$db = mysql_select_db($database, $server);
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM `storys` WHERE id = $id");
$row = mysql_fetch_row($sql);
?>
<div>
<a href="javascript:ajaxpage('includes/story_comment_whole.php?id=%s', 'comments');">Comments</a><br />
<div id="comments">
</div>
<br /><br />
</div>
<?php
print "<b>$row[1]</b> by $row[2]<br><br>";
print nl2br($row[3]);
?>
<br /><br />
<a href="javascript:ajaxpage('stories.php', 'contentarea');">Back to the story page</a><br /><br />
Code:
<?php $host = "mysql10.streamline.net"; $username = "pass"; $password = "usr"; $database = "db"; $server = mysql_connect($host, $username, $password); $connection = mysql_select_db($database, $server); $server = mysql_connect($host, $username, $password); $db = mysql_select_db($database, $server); $id = $_GET['id']; ?> <div id="globalNav"> <div> </div> </div> <div id="headlines"> <h3>Add a comment:</h3> </div> <div id="content"> <div> <?php print "<form action=\"storys_comment2.php?id=$id\" method=\"post\">"; ?> Name: <br /> <input type="textbox" name="name"><br /> Comment: <br /><textarea name="comment" rows="5" cols="40"></textarea><br /> <input type="submit" value="Submit"> </form> </div> </div> Code:
<?php
$host = "mysql10.streamline.net";
$username = "usr";
$password = "pass";
$database = "db";
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
$server = mysql_connect($host, $username, $password);
$db = mysql_select_db(jennifersp, $server);
$id = $_GET['id'];
$story_id = $_POST['story_id'];
$name = $_POST['name'];
$comment = $_POST['comment'];
?>
<div id="globalNav">
<div>
</div>
</div>
<div id="headlines">
<h3>Add a comment:</h3>
</div>
<div id="content">
<div>
<?php
$sql = 'INSERT INTO `storys_comments` (`id`, `story_id`, `name`, `comment`) VALUES (\'\', \''.$id.'\', \''.$name.'\', \''.$comment.'\');';
$query = mysql_query($sql);
if(!query) {
print "Error! mysql_error()";
} else {
print "Addition successful";
print "
<script>
setTimeout(\"top.topiframe.location = './story_comments.php?id=".$id."'\", 9);
</script>
";
}
?>
</form>
</div>
</div>
<!-- end content -->
<div id="navBar">
Code:
<form name="story" action="./uploader.php" method="post">
<br>
<br>
<br>
<table width="80%" border="0" cellpadding="0" align="center">
<tr>
<td>Author:</td>
<td><div align="right">
<input type="text" name="author" />
</div></td>
</tr>
<tr>
<td>Title:</td>
<td><div align="right">
<input type="text" name="title" />
</div></td>
</tr>
<tr>
<td colspan="2"><textarea name="body" cols="65" rows="25"></textarea></td>
</tr>
<tr>
<td><input name="bn_submit" type="submit" value="Submit" /></td>
<td> </td>
</tr>
</table>
</form>
Code:
<?php
//story upload
$host = "mysql10.streamline.net";
$username = "usr";
$password = "pass";
$database = "db";
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
//grab data from form
$author = $_POST['author'];
$title = $_POST['title'];
$body = $_POST['body'];
$server = mysql_connect($host, $username, $password);
$db = mysql_select_db($database, $server);
$sql_phrase = 'INSERT INTO `storys` (`id`, `author`, `title`, `body`) VALUES (\'\',\''.$author.'\', \''.$title.'\', \''.$body. '\');';
$sql = mysql_query($sql_phrase);
if(!$sql) {
echo "There was an error, please try again.";
print mysql_error();
}
else
echo "uploaded";
?>
|
|
|
|
| babyjenniferLB |
| View Public Profile |
| Find More Posts by babyjenniferLB |
|
|
#16 |
|
Thread Starter
macrumors 65816
Join Date: Jan 2006
Location: Scotlands
|
oh i sould mention this is how it is displayed
Code:
<script type="text/javascript">
var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""
function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}
function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}
function loadobjs(){
if (!document.getElementById)
return
for (i=0; i < arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}
</script>
<script type="text/javascript">
var rootdomain="http://"+window.location.hostname
function ajaxinclude(url) {
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.open('GET', url, false) //get page synchronously
page_request.send(null)
writecontent(page_request)
}
function writecontent(page_request){
if (window.location.href.indexOf("http")==-1 || page_request.status==200)
document.write(page_request.responseText)
}
</script>
<script type="text/javascript">
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=600');");
}
// End -->
</script>
<div id="apDiv1">
<div id="apDiv2">
<h2>Welcome to the Stories Archive</h2>
<br />
<p>You will find here and extensive collection of stories. Even better than that, this story archive is easy to use.</p>
<p>The Stories are listed in order of newest to oldest so the latest story will always be right at the top of the list for you to read.</p>
<p>As an added bonus, you can view and add comments about the stories, this is great if you find a problem with a story, or just want to make general comments.</p>
<p>You too can add stories to the story archive to share with everyone.</p>
<p>Enjoy searching through the stories ^_^</p>
<p> </p>
<a href="/themes/zen/storys_uploads.php">Add a new story</a>
</div>
<?php
$host = "mysql10.streamline.net";
$username = "usr";
$password = "pass";
$database = "db";
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
$server = mysql_connect($host, $username, $password);
$db = mysql_select_db($database, $server);
$sql = mysql_query('SELECT * FROM `storys` ORDER BY `id` DESC');
print "<table><tr><th>Story</th><th>Author</th><th>Comments</th></tr>";
while($row = mysql_fetch_array($sql, MYSQL_BOTH)) {
printf("<tr><td><A HREF=\"javascript:ajaxpage('/includes/story_display.php?id=%s', 'contentarea');\">%s</a></td><td><span style=\"TEXT-ALIGN:center\">%s</span></td><td colspan=2><A HREF=\"javascript:ajaxpage('/includes/story_comment_whole.php?id=%s', 'comment');\">Comments</a><br /><br /></td>", $row["id"], $row["title"], $row["author"], $row["id"]);
}
?>
</table>
<br/ >
</div>
<br/ >
Code:
<?php
print "<IFRAME SRC=\"includes/story_comments.php?id=".$_GET['id']."\" width=\"100%\" height=\"325\" frameborder=\"0\" name=\"topiframe\"></IFRAME><br />";
?>
<br />
<a href="javascript:ajaxpage('includes/newcomment.php', 'addnew');">Add new comment</a>
<div id="addnew">
</div>
Last edited by babyjenniferLB : Jun 6, 2007 at 04:36 PM. |
|
|
|
| babyjenniferLB |
| View Public Profile |
| Find More Posts by babyjenniferLB |
|
|
#17 |
|
macrumors newbie
Join Date: Oct 2006
|
First of all, you should first escape all your inputs, as your current code is vulnerable to sql injection.
The problem you're having is, when $id is null, or is not set, then the SQL query you are doing is Code:
SELECT * FROM storys_comments WHERE story_id = ORDER BY id DESC When set to anything other than a number, such as... http://www.test.jennifersplaygroup.c...ments.php?id=1 OR 1=1 the query becomes Code:
SELECT * FROM storys_comments WHERE story_id =1 OR 1=1 ORDER BY id DESC instead, what you should do is check whether $id is set first and that it is numeric.. You should also do some error checking. Try something like this Code:
$host = "mysql10.streamline.net";
$username = "usr";
$password = "pass";
$database = "db";
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
$db = mysql_select_db($database, $server);
if (isset($_GET['id']) and is_numeric($_GET['id'])) {
$id = $_GET['id'];
} else {
exit ('invalid id');
}
$sql = mysql_query("SELECT * FROM storys_comments WHERE story_id = $id ORDER BY id DESC");
if (!$sql) {
exit ('Error retrieving comments..');
}
while ($row = mysql_fetch_array ($sql)) {
print nl2br(htmlspecialchars($row[3]));
print "<br />By " . htmlspecialchars($row[2]) . "<br /><hr><br />";
}
Last edited by oookye : Jun 10, 2007 at 10:41 PM. |
|
|
|
|
|
#18 |
|
Thread Starter
macrumors 65816
Join Date: Jan 2006
Location: Scotlands
|
i found out that its just not getting the right id form the other page, is there a way for me to do something like
$id = otherpage.php(id) as it is the other pages id it needs to aquire. |
|
|
|
| babyjenniferLB |
| View Public Profile |
| Find More Posts by babyjenniferLB |
|
|
#19 | |
|
macrumors 68000
|
Quote:
You need to pass it as a variable. You can do something like this, make the link look like: http://myserver.com/mypage.php?id=1234 That "?id=1234" tells PHP to make a variable called $_GET['id'] with the value 1234 in it. Listen to what others are saying about SQL injection...people can do nasty thing with your site. The quick fix is to wrap all your "dirty" parameters in quotes, like this: SELECT * FROM MYTABLE WHERE id='$id' Notice that this works even for numbers, despite the quotation marks. Then you also need to escape any dangerous characters in the $id variable, like this: $id = mysql_real_escape_string($id, $db_connection); This is off the top of my head and the actual syntax may be wrong. The PHP manual is your friend. When I have problems with SQL embedded in PHP, I do this: 1) In your script, store the query you want to execute in a variable,like $my_query. 2) Print out this variable either with <pre> tags or in an HTML comment, e.g. print("<pre>$my_query</pre>\n"); That makes it easier to read. 3) Cut and paste from the debug output into a SQL tool, like phpMyAdmin, or even the mysql command line tool. Run it with this tool. This way you see the exact error message, and you can also look at your data and data structures directly.
__________________
Mehce
|
|
|
|
|
|
|
#20 |
|
Thread Starter
macrumors 65816
Join Date: Jan 2006
Location: Scotlands
|
ok im giving a few things a try it seems to be printing out invalid id, this may be because of the way the page is set up with ajax that the two php documents are not seeing each other properly so im going to try to solve it as best i can. secureing the code is on my list of things to do but only once it all works.
|
|
|
|
| babyjenniferLB |
| View Public Profile |
| Find More Posts by babyjenniferLB |
|
|
#21 |
|
Thread Starter
macrumors 65816
Join Date: Jan 2006
Location: Scotlands
|
ok so the current formula
Index.html, this is the main page Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Ajax Tech Demo Dynamic page loads</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css" />
<script type="text/javascript">
var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""
function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}
function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}
function loadobjs(){
if (!document.getElementById)
return
for (i=0; i < arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}
</script>
<script type="text/javascript">
var rootdomain="http://"+window.location.hostname
function ajaxinclude(url) {
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.open('GET', url, false) //get page synchronously
page_request.send(null)
writecontent(page_request)
}
function writecontent(page_request){
if (window.location.href.indexOf("http")==-1 || page_request.status==200)
document.write(page_request.responseText)
}
</script>
</head>
<body>
<div id="container">
<div id="Layer1">
<div id="logo_container">
<table width="500px" >
<tr class="logo">
<td><a href="?q=forum" class="frm"></a></td>
<td><a href="?q=babblechat" class="cht"></a></td>
<td><a href="javascript:ajaxpage('stories.php', 'contentarea');" class="str"></a></td>
<td><a href="?q=video" class="vid"></a></td>
<td><a href="javascript:ajaxpage('links.html', 'contentarea');" class="lin"></a></td>
<td><a href="?q=blog" class="blo"></a></td>
</tr>
<tr class="logo">
<td><a href="?q=image" class="img"></a></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</div></div>
<img src="/img/web-banner.jpg" alt="banner" />
<div id="left-block">
<script type="text/javascript">
ajaxinclude("includes/blocks/stoires_block.php")
</script>
</div>
<div id="content">
<a href="javascript:ajaxpage('home.html', 'contentarea');">home</a>
<br /><br />
<div id="contentarea">
<h2>Welcome</h2>
<br />
Welcome to the playgroup, our community has over 492 registered members. The playgroup is a online community for everyone to enjoy, learn and share. You are key to making this site a great place to be. <br /><br />
This side deals with infantilism, Adult Babies, Teen Babies, Diaper lovers, Age Player, and there respective parents and carers are all welcome here. Our forum is here for everyone to share their experience or to just talk to other like minded individuals it is open to all of our users.
<br />
<br />
<h3>Announcement</h3>
Everyday at 9PM London time you can speak to me Jerry Louise on the chat network.
<br />
<br />
<h3>Main Pages</h3>
The main pages on the site are the forum, stories, image gallery's and the user blogs. You as users can post to any of these pages new content and comments on existing content.
<br /><br />
Forum: Works like every other forum check it out.
<br /><br />
Stories Page: As is says on the tin post stories here and read other users stories , you can also comment on any story posted.
<br /><br />
Image Galleries: Post your own images here, you can now create your own album by clicking on the album link in the "Create Content" block.
<br /><br />
Blogs: To create a Blog just goto the "Create content" module and click "Blog entry". A Blog is a bit like a diary that other users can read.
<br /> <br />
<h3>Get involved</h3>
So you sign up and say to yourself "what now", well the answer is simple, contribute to the site, as a user you can create your own blog, forum topics and replies, you can also add comments to most articles, images and videos.
<br /><br />
More features will be added soon such as the return of the stories and tips and tricks pages and the addition of the support pages to complement the forum.
<br /><br />
You will notice there are a few albums, currently users can not create there own, in order to get your own album you can request it by pm'ing me, but user gallery's are only for your own content, you must own the copyright to the images.
<br /><br />
As always if you have any problems you can message me using the pm network. <br />
<br />
<h3>Request a feature</h3>
Please add your feature requests here, i need to know what you want in order to make this site our community. To add a feature request simply click on the link add new comment
<br /><br />
Thanks Jerry Louise
</div>
<br /><br />
<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml10"
alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
</p>
</div>
<img src="/img/logo_bottom.jpg" alt="banner" />
</div>
</body>
</html>
stories.php, opens up inside contentarea witch is a div tag inside index.html Code:
<script type="text/javascript">
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=600');");
}
// End -->
</script>
<div id="apDiv1">
<div id="apDiv2">
<h2>Welcome to the Stories Archive</h2>
<br />
<p>You will find here and extensive collection of stories. Even better than that, this story archive is easy to use.</p>
<p>The Stories are listed in order of newest to oldest so the latest story will always be right at the top of the list for you to read.</p>
<p>As an added bonus, you can view and add comments about the stories, this is great if you find a problem with a story, or just want to make general comments.</p>
<p>You too can add stories to the story archive to share with everyone.</p>
<p>Enjoy searching through the stories ^_^</p>
<p> </p>
<a href="/themes/zen/storys_uploads.php">Add a new story</a>
</div>
<?php
$host = "mysql10.streamline.net";
$username = "usr";
$password = "pass";
$database = "db";
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
$server = mysql_connect($host, $username, $password);
$db = mysql_select_db($database, $server);
$sql = mysql_query('SELECT * FROM `storys` ORDER BY `id` DESC');
print "<table><tr><th>Story</th><th>Author</th><th>Comments</th></tr>";
while($row = mysql_fetch_array($sql, MYSQL_BOTH)) {
printf("<tr><td><A HREF=\"javascript:ajaxpage('/includes/story_display.php?id=%s', 'contentarea');\">%s</a></td><td><span style=\"TEXT-ALIGN:center\">%s</span></td><td colspan=2><A HREF=\"javascript:ajaxpage('/includes/story_comment_whole.php?id=%s', 'comment');\">Comments</a><br /><br /></td>", $row["id"], $row["title"], $row["author"], $row["id"]);
}
?>
</table>
<br/ >
</div>
<br/ >
Code:
<?php
$host = "mysql10.streamline.net";
$username = "usr";
$password = "pass";
$database = "db";
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
$server = mysql_connect($host, $username, $password);
$db = mysql_select_db($database, $server);
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM `storys` WHERE id = $id");
$row = mysql_fetch_row($sql);
?>
<div>
<a href="javascript:ajaxpage('includes/story_comments.php?id=%s', 'comments');">Comments</a>
<div id="comments">
</div>
<br />
<a href="javascript:ajaxpage('includes/newcomment.php', 'addnew');">Add new comment</a>
<div id="addnew">
</div>
<br /><br />
</div>
<?php
print "<b>$row[2]</b> by $row[1]<br><br>";
print nl2br($row[3]);
?>
<br /><br />
<a href="javascript:ajaxpage('stories.php', 'contentarea');">Back to the story page</a><br /><br />
Code:
<?php $host = "mysql10.streamline.net"; $username = "usr"; $password = "pass"; $database = "db"; $server = mysql_connect($host, $username, $password); $connection = mysql_select_db($database, $server); $server = mysql_connect($host, $username, $password); $db = mysql_select_db($database, $server); $id = $_GET['id']; ?> <div id="globalNav"> <div> </div> </div> <div id="headlines"> <h3>Add a comment:</h3> </div> <div id="content"> <div> <?php print "<form action=\"storys_comment2.php?id=$id\" method=\"post\">"; ?> Name: <br /> <input type="textbox" name="name"><br /> Comment: <br /><textarea name="comment" rows="5" cols="40"></textarea><br /> <input type="submit" value="Submit"> </form> </div> </div> |
|
|
|
| babyjenniferLB |
| View Public Profile |
| Find More Posts by babyjenniferLB |
|
|
#22 |
|
Thread Starter
macrumors 65816
Join Date: Jan 2006
Location: Scotlands
|
dang this is annoying me.
|
|
|
|
| babyjenniferLB |
| View Public Profile |
| Find More Posts by babyjenniferLB |
|
|
#23 |
|
macrumors regular
Join Date: Mar 2007
|
I just visited the site, http://test.jennifersplaygroup.co.uk/ and saw a series of Notice: errors under the Stories menu on the left of the page. Are these the errors you are currently trying to fix (see attached)?
We will need to see the code on your file /includes/blocks/stoires_block.php (note the misspelled filename, this is how the file is actually spelled - maybe this is causing some other issues?). The error you had in a previous post was corrected by adding quotation marks around your array keys. I would imaging that since the Notice warnings are the same, that the same issue is occurring. So look for something on line 18 of the file stoires_block.php that looks like: Code:
$row[id] Code:
$row["id"] Are there other errors you are still getting? |
|
|
|
| macfaninpdx |
| View Public Profile |
| Find More Posts by macfaninpdx |
|
|
#24 | |
|
Thread Starter
macrumors 65816
Join Date: Jan 2006
Location: Scotlands
|
Quote:
|
|
|
|
|
| babyjenniferLB |
| View Public Profile |
| Find More Posts by babyjenniferLB |
|
|
#25 |
|
Thread Starter
macrumors 65816
Join Date: Jan 2006
Location: Scotlands
|
Anyway to get it to work like this having all the code on the same page.
Code:
<?php
$host = "mysql10.streamline.net";
$username = "jennifersp";
$password = "s92630";
$database = "jennifersp";
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
$server = mysql_connect($host, $username, $password);
$db = mysql_select_db($database, $server);
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM `storys` WHERE id = $id");
$row = mysql_fetch_row($sql);
?>
<?php
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM storys_comments WHERE story_id = $id ORDER BY story_id DESC");
while ($row = mysql_fetch_array ($sql)) {
print nl2br($row[3]);
print "<br />By $row[2]<br /><hr><br />";
}
?>
<div>
<a href="javascript:ajaxpage('includes/story_comments.php?id=%s', 'comments');">Comments</a>
<div id="comments">
</div>
<br />
<a href="javascript:ajaxpage('includes/newcomment.php', 'addnew');">Add new comment</a>
<div id="addnew">
</div>
<br /><br />
</div>
<?php
print "<b>$row[2]</b> by $row[1]<br><br>";
print nl2br($row[3]);
?>
<br /><br />
<a href="javascript:ajaxpage('stories.php', 'contentarea');">Back to the story page</a><br /><br />
|
|
|
|
| babyjenniferLB |
| View Public Profile |
| Find More Posts by babyjenniferLB |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|