Unstoppable Domains

News system

Spaceship Spaceship
Watch

Albino

Munky DesignsEstablished Member
Impact
17
ok, im using this tut (http://localhost/news_system/index.php) to make a news system. I have edited it so i have a php file to make the tables, and they are created fine.

I have also changed the connect settings so it connects to my mysql.

I have mysql 4.1, and php 4.

however, whenever I run the index, i get this error:

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Group\Apache2\test\news_system\index.php on line 10

I cant figure out how to fix it.

Can anyone help?
Thanks
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
It's not connecting to the database properly or the query is not right. Post your code, please!
 
0
•••
link XP said, you sure have rights to make an database with full permission ? also edited the config file inside the files.

aswell you checked the documentation. ?
 
0
•••
ok, bit more info for ya :D

here is how i make my tables:

Code:
<?php

$dbhost="localhost";
$dbusername="root";
$dbpassword="pass";
$dbname="bombibiza";

$connect = mysql_connect($dbhost, $dbusername, $dbpassword);

mysql_create_db("bombibiza") or die (mysql_error());

mysql_select_db("bombibiza");


$Main = "CREATE TABLE `news` (
  `newsid` int(11) NOT NULL auto_increment;
  `dtime` datetime default NULL;
  `title` varchar(255) default NULL;
  `text1` text;
  `text2` text;
  PRIMARY KEY  (`newsid`)
) TYPE=MyISAM AUTO_INCREMENT=1  "  ;

echo "tables are complete"
?>

obviously I have changed my password.

here is the code for the index, the higlighted line is the one that is having the error.


Code:
<?php
// load the configuration file.
include("config.php");
        //load all news from the database and then OREDER them by newsid
        //you will notice that newlly added news will appeare first.
        //also you can OREDER by (dtime) instaed of (news id)
        $result = mysql_query("SELECT * FROM news ORDER BY newsid DESC",$connect);
        //lets make a loop and get all news from the database
        *****while($myrow = mysql_fetch_row($result))*****
             {//begin of loop
               //now print the results:
               echo "<b>Title: ";
               echo $myrow[2];
               echo "</b><br>On: <i>";
               echo $myrow[1];
               echo "</i><hr align=left width=160>";
               echo $myrow[3];
               // Now print the options to (Read,Edit & Delete the news)
               echo "<br><a href=\"read_more.php?newsid=$myrow[newsid]\">Read More...</a>
                || <a href=\"edit_news.php?newsid=$myrow[newsid]\">Edit</a>
                 || <a href=\"delete_news.php?newsid=$myrow[newsid]\">Delete</a><br><hr>";
             }//end of loop
?>

in the config, all i have is my connection to the database:

Code:
<?php
// Set Mysql Variables
//Change the following
$dbhost="localhost";
$dbusername="root";
$dbpassword="pass";
$dbname="bombibiza";

// Don't touch here anything.
// Connect to Mysql
$connect = mysql_connect($dbhost, $dbusername, $dbpassword);
//Select the correct database.
mysql_select_db($dbname,$connect) or die ("Could not select database");
?>

also, ive realised i posted the wrong link to the tutorial, here is the real link:

http://www.maaking.com/index.php?loadpage=tutorials

cheers if anyone can help me
 
0
•••
In the create mysql db there shouldn't be a ; there should only be commas..

Fixed:
PHP:
$Main = "CREATE TABLE `news` (
  `newsid` int(11) NOT NULL auto_increment,
  `dtime` datetime default NULL,
  `title` varchar(255) default NULL,
  `text1` text,
  `text2` text,
  PRIMARY KEY  (`newsid`)
) TYPE=MyISAM AUTO_INCREMENT=1  "  ;

As well the last entry shouldn't have any ; or ,

This should work. Due to this fact the db may not be created which would cause that error.

Try check phpMyAdmin to see if the db was created.

Regards,
 
0
•••
ooo

good point, didnt notice that!


thanks, i shall try that in a moment
 
0
•••
Also, when posting PHP code at all, use [ PHP ], not [ CODE ].
 
0
•••
As well I like the fact you used comments in your coding.. This is a great thing which many programs leave out. It allows you to easly scan through to fix bugs, errors without any real trouble.

If you have any problems please post them one fo the talented programmers here will help you very fast.

iNod
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back