[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 08-10-2005, 04:50 AM   #1 (permalink)
Munky Designs
 
Join Date: May 2005
Posts: 997
417.00 NP$ (Donate)

Albino is a jewel in the roughAlbino is a jewel in the roughAlbino is a jewel in the rough


news system

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
Albino is offline  
Old 08-10-2005, 06:18 AM   #2 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future

Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
It's not connecting to the database properly or the query is not right. Post your code, please!
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 08-10-2005, 06:33 AM   #3 (permalink)
Pro Coder & Designer
 
xlusive's Avatar
 
Join Date: Apr 2005
Location: Netherlands
Posts: 964
101.50 NP$ (Donate)

xlusive is just really nicexlusive is just really nicexlusive is just really nicexlusive is just really nicexlusive is just really nice


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. ?
__________________
Online Dragonball Game
xlusive is offline  
Old 08-10-2005, 02:35 PM   #4 (permalink)
Munky Designs
 
Join Date: May 2005
Posts: 997
417.00 NP$ (Donate)

Albino is a jewel in the roughAlbino is a jewel in the roughAlbino is a jewel in the rough


ok, bit more info for ya

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
Albino is offline  
Old 08-10-2005, 02:43 PM   #5 (permalink)
Eating Pie
 
iNod's Avatar
 
Join Date: Nov 2004
Location: Canada
Posts: 2,289
126.05 NP$ (Donate)

iNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud of

Special Olympics AIDS/HIV Cystic Fibrosis Save The Children Baby Health Cystic Fibrosis
In the create mysql db there shouldn't be a ; there should only be commas..

Fixed:
PHP Code:
$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,
__________________
I feel old.
iNod is offline  
Old 08-10-2005, 02:59 PM   #6 (permalink)
Munky Designs
 
Join Date: May 2005
Posts: 997
417.00 NP$ (Donate)

Albino is a jewel in the roughAlbino is a jewel in the roughAlbino is a jewel in the rough


ooo

good point, didnt notice that!


thanks, i shall try that in a moment
Albino is offline  
Old 08-10-2005, 03:14 PM   #7 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future

Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
Also, when posting PHP code at all, use [ PHP ], not [ CODE ].
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 08-10-2005, 05:41 PM   #8 (permalink)
Eating Pie
 
iNod's Avatar
 
Join Date: Nov 2004
Location: Canada
Posts: 2,289
126.05 NP$ (Donate)

iNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud of

Special Olympics AIDS/HIV Cystic Fibrosis Save The Children Baby Health Cystic Fibrosis
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
__________________
I feel old.
iNod is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
WHMCompleteSolution Client Management, Billing & Support System for cPanel & WHM Host thewishbone For Sale / Advertising Board 0 08-08-2005 10:10 AM
Domain Name System in Need of Upgrade Cheapquality Industry News 0 04-06-2005 04:38 PM
News Manager System Needing Coded! norbx Programming 5 04-05-2005 03:11 PM
News Manager System Needing Coded! norbx Website Development 0 04-05-2005 10:29 AM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 03:25 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85