Current location: Hot Scripts Forums » Programming Languages » PHP » Not loading from MySQL database, i dont know whats wrong with the code


Not loading from MySQL database, i dont know whats wrong with the code

Reply
  #1 (permalink)  
Old 02-12-05, 01:51 AM
alfrin alfrin is offline
Newbie Coder
 
Join Date: Feb 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Not loading from MySQL database, i dont know whats wrong with the code

I changed the database table that i was using, i change what i though need to be changed, can any one help, heres the code:
it was "news" but i changed i to emc_news
Code:
<?php $page_title = "Title Here";
include 'library/config.php';
include 'library/opendb.php';

$query="SELECT * FROM `ems_news` WHERE 1";
$news = mysql_query($query);
$num = mysql_numrows($news);
mysql_close();
 ?>
<!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>
<title>CSS Page Template - Three Column Pixel Perfect - Header
&amp; Footer</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css"
href="css/first.css" />
</head>
<body>
<?php include '/includes/header.php'; ?>
<div id="c-block">
<div id="c-col">
<h3 align="center">Three Column Pixel Perfect with Header &amp;
Footer - MK 1</h3>
<div align="center" style="color:red;">Ver 2.3</div>
<p>&nbsp;&nbsp;&nbsp;&nbsp; This program is intended to be free under the GPL/GNU liceansing and Should for <strong>NO</strong> reason whatsoever be sold at any price. The program is fully commented and should stay that way. </p>
<p> The only place in which I allocate this source to be publicly developed is at <a href="http://www.beta-projects.org" title="Beta Projects" target="_blank">Beta-Projects</a>. I would appreciate it if you kept the copyright notice on the bottom of this page when installing this on your website.</p>
<p>Also this site is built on donations and any would be appreciated. </p>
<p>&nbsp;</p>
<hr />
 <?php
 $i=$num;
 while ($i <= $num && $i > 0){
 $title=mysql_result($news,$i,"title");
 $content=mysql_result($news,$i,"content");
 echo "<strong>$title</strong><br />$content<br /><br />";
 $i--;
 }
 ?>
<br />
</div>
<!-- end of center column -->
</div>
<!-- end c-block -->
<div id="ftr" align="center">
  <p>&copy;Copyright MamerCorp 2005 </p>
  </div>
<!-- left column -->
<div id="lh-col">
     Navigation <br />
     <br />
     <br />
     <br />
     <br />
     <br />
     <br />
     <br />
  
</div>
<!-- end of left column -->
<!-- right column -->
<div id="rh-col"><br />
<h4 align="center">Right Column</h4>
<p align="center">More links?<br />
Advertisements?</p>
</div>
<!-- end of right column -->
</body>
</html>

Last edited by alfrin; 02-12-05 at 01:53 AM.
Reply With Quote
  #2 (permalink)  
Old 02-12-05, 06:27 AM
ben.periton ben.periton is offline
Wannabe Coder
 
Join Date: Oct 2004
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
You said you changed it to emc_news but you have ems_news
query="SELECT * FROM `ems_news` WHERE 1";
__________________
Ben Periton
http://ben.periton.co.uk
Reply With Quote
  #3 (permalink)  
Old 02-12-05, 11:09 AM
alfrin alfrin is offline
Newbie Coder
 
Join Date: Feb 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
weird, i dont know where that came from, it still doenst work after removing it
Reply With Quote
  #4 (permalink)  
Old 02-12-05, 11:50 AM
Tempestshade Tempestshade is offline
Newbie Coder
 
Join Date: Aug 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
don't remove it change it to
query="SELECT * FROM `emc_news` WHERE 1";
__________________
http://www.cashbackhosting.net - Cashback Hosting. Cheap Web Hosting starting at $1.50
Reply With Quote
  #5 (permalink)  
Old 02-12-05, 11:59 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
2 notes:
- use or die() after mysql_query()
- it's mysql_num_rows() not mysql_numrows().. the latter one is deprecated ..

PHP Code:

$news mysql_query($query)or

die(
mysql_error());

$num mysql_num_rows($news); 
I suggest you raise the error reporting level by putting:
PHP Code:

error_reporting(E_ALL): 

at the top of each page to help you debugging your code,,,


and please use [ php ] instead of [ code ] to color your code..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]

Last edited by NeverMind; 02-12-05 at 12:14 PM.
Reply With Quote
  #6 (permalink)  
Old 02-12-05, 03:26 PM
alfrin alfrin is offline
Newbie Coder
 
Join Date: Feb 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Question

Quote:
Originally Posted by NeverMind
2 notes:
- use or die() after mysql_query()
- it's mysql_num_rows() not mysql_numrows().. the latter one is deprecated ..

PHP Code:

$news mysql_query($query)or

die(
mysql_error());

$num mysql_num_rows($news); 
I suggest you raise the error reporting level by putting:
PHP Code:

error_reporting(E_ALL): 

at the top of each page to help you debugging your code,,,


and please use [ php ] instead of [ code ] to color your code..
O, didn't see the php code, anyways ive changed the stuff but its loading from the wrong table now, which doenst make sense since it doesnt exist, on the admin page it loads from the right place, maybe it would help to show the page http://www.codingsource.org/ems/index.php and the admin page http://www.codingsource.org/ems/admin/admin.php
Reply With Quote
Reply

Bookmarks


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

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Form to update a MySQL database? Scoobler PHP 9 09-04-08 01:41 AM
Error while creating database (Errornumber 2002: "Can't connect to local MySQL server lylesback2 PHP 5 04-11-04 01:37 PM
Loading an image into database with customerID pecobrown PHP 2 02-27-04 01:11 PM
Generating PHP code for MySQL ptesone General Advertisements 1 02-03-04 08:26 AM


All times are GMT -5. The time now is 05:29 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.