| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| Munky Designs | 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 |
| |
| | #2 (permalink) |
| DNOA Member | 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! |
| |
| | #3 (permalink) |
| Pro Coder & Designer | 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 |
| |
| | #4 (permalink) |
| Munky Designs | 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"
?>
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
?>
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");
?>
http://www.maaking.com/index.php?loadpage=tutorials cheers if anyone can help me |
| |
| | #5 (permalink) |
| Eating Pie | In the create mysql db there shouldn't be a ; there should only be commas.. Fixed: PHP Code: 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. |
| |
| | #7 (permalink) |
| DNOA Member | 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! |
| |
| | #8 (permalink) |
| Eating Pie | 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. |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
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 |