Intranet Journal

Go Back   IT Management Forum > Intranet Journal

Intranet Journal The new discussion forum for Intranet Journal readers. Leave comments and questions for IJ authors. Suggest story ideas and provide feedback.

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 12-22-2009, 12:38 PM
k4supur3 k4supur3 is offline
Registered User
 
Join Date: Dec 2009
Posts: 2
mysql_fetch_array() problem

Hello!
Im trying to make an code which shows my post in list and after it there's a link for delete button which allows to delete the post, but im stuck with this problem :

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in E:\Ohjelmat\Xampp\htdocs\VBS\includes\DbConnector. php on line 50


The code which makes the error
Code:
<?php
// LIST SECTIONS /////////////////////////////////////////////////////////////////////
$result = $connector->query('SELECT ID,name,parentid FROM vbsarticles');

// Get an array containing the results.
// Loop for each item in that array
while ($row = $connector->fetchArray($result)){
	echo $row['name'].' -    '; // Show the name of section
	echo '<a href="deletearticle.php?action=delete&id='.$row['ID'].'"> Delete </a>'; // Show the delete link 
	echo '<br>'; // Show a carriage return
}
?>
DBConnector.php code
Code:
<?php
////////////////////////////////////////////////////////////////////////////////////////
// Class: DbConnector
// Purpose: Connect to a database, MySQL version
///////////////////////////////////////////////////////////////////////////////////////
require_once 'SystemComponent.php';

class DbConnector extends SystemComponent {

var $theQuery;
var $link;

//*** Function: DbConnector, Purpose: Connect to the database ***
function DbConnector(){

	// Load settings from parent class
	$settings = SystemComponent::getSettings();

	// Get the main settings from the array we just loaded
	$host = $settings['dbhost'];
	$db = $settings['dbname'];
	$user = $settings['dbusername'];
	$pass = $settings['dbpassword'];

	// Connect to the database
	$this->link = mysql_connect($host, $user, $pass);
	mysql_select_db($db);
	register_shutdown_function(array(&$this, 'close'));

}

//*** Function: query, Purpose: Execute a database query ***
function query($query) {
	$this->theQuery = $query;
	return mysql_query($query, $this->link);
}

//*** Function: getQuery, Purpose: Returns the last database query, for debugging ***
function getQuery() {
	return $this->theQuery;
}

//*** Function: getNumRows, Purpose: Return row count, MySQL version ***
function getNumRows($result){
	return mysql_num_rows($result);
}

//*** Function: fetchArray, Purpose: Get array of query results ***
function fetchArray($result) {
	return mysql_fetch_array($result);
}

//*** Function: close, Purpose: Close the connection ***
function close() {
	mysql_close($this->link);
}


}
?>
Reply With Quote
  #2 (permalink)  
Old 12-22-2009, 03:38 PM
k4supur3 k4supur3 is offline
Registered User
 
Join Date: Dec 2009
Posts: 2
I got it to work, i forgot to change the query names....
Code:
$result = $connector->query('SELECT ID,name,parentid FROM vbsarticles');
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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




All times are GMT -5. The time now is 09:25 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0