What's Wrong With this Script?

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
p3
-


Joined: 17 Jun 2005
Posts: 615

PostPosted: Fri Feb 10, 2006 4:24 am    Post subject: What's Wrong With this Script? Reply with quote

Whenever I try to run this script, I get no results for whatever reason. No errors or warnings are thrown, but the data from the db never shows up. The script is below:

Code:

<?php include ('header.php'); ?>

Welcome to P3NET!<br><br>
<hr>
Click a link to get started<hr>
<?php
include('db_connect.php');
$get_index_posts = "SELECT * FROM 'index_page' ORDER BY 'id' DESC LIMIT 2";
$index_query = mysql_query($get_index_posts);
$num = mysql_numrows($index_query);
$i=0;
while ($i < 2)
{
   $title= mysql_result($index_query,$i,"title");
   $content= mysql_result($index_query,$i,"content");
   
   echo "<b>$title</b><br><br>$content<hr>";
   $i++;
}
?>
Pagehits since October 15, 2005:<br>
<!-- Start of StatCounter Code -->
<script type="text/javascript" language="javascript">
<!--
var sc_project=989048;
var sc_invisible=0;
var sc_partition=9;
var sc_security="6cc998ac";
//-->
</script>

<script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript><img  src="http://c10.statcounter.com/counter.php?sc_project=989048&java=0&security=6cc998ac&invisible=0" alt="unique visitors counter" border="0"> </noscript>
<!-- End of StatCounter Code -->

<?php include ('footer.php'); ?>

You can see what it does produce here

Thanks!
[EDIT]
Played around with my settings in php.ini, and I now see this:

Quote:

An error occured while parsing this PHP file. Error:


Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in F:\test\index.php on line 10
An error occured while parsing this PHP file. Error:


Warning: mysql_result(): supplied argument is not a valid MySQL result resource in F:\test\index.php on line 14
An error occured while parsing this PHP file. Error:


Warning: mysql_result(): supplied argument is not a valid MySQL result resource in F:\test\index.php on line 15


An error occured while parsing this PHP file. Error:


Warning: mysql_result(): supplied argument is not a valid MySQL result resource in F:\test\index.php on line 14
An error occured while parsing this PHP file. Error:


Warning: mysql_result(): supplied argument is not a valid MySQL result resource in F:\test\index.php on line 15

However, for security reasons, I'm disabling warnings for now (again)
[/EDIT]
[EDIT AGAIN]
Well, more info for you. I am using PHP 4 and MySQL 4
[/EDIT]
Back to top View user's profile Send private message Send e-mail
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Fri Feb 10, 2006 5:35 am    Post subject: Reply with quote

Code:
$get_index_posts = "SELECT * FROM 'index_page' ORDER BY 'id' DESC LIMIT 2";

Use mysql_error() to find out what's wrong, as far as I can see it's because you used ''s. (Although I don't know if you can or not, it's better to use ``s or nothing at all.)
Code:
$get_index_posts = "SELECT * FROM `index_page` ORDER BY `id` DESC LIMIT 2";

Note: Use ''s on values though.
E.G.
Code:
UPDATE `table1` SET `teh_funnay` = 'absent', `chuck_norris` = 'lepwn' WHERE `internets` = 'true'

_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
p3
-


Joined: 17 Jun 2005
Posts: 615

PostPosted: Fri Feb 10, 2006 3:12 pm    Post subject: Reply with quote

It worked when I removed the ' 's
Back to top View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group