Jump to content

New to PHP noob question!


pyrox

Recommended Posts

why does this statement error

 

Function Getmailcount($UserID)

{

$dbhost="?????";

$dbpass="????";

$dbuser="???";

$database="????";

 

mysql_connect($dbhost, $dbuser, $dbpass)

      or die("The site database appears to be down.");

 

      @mysql_select_db($database) or die( "Unable to select database");

 

 

 

 

$sqlmail= "SELECT * FROM messsages WHERE to = '$UserID' AND to_viewed = '0'";

$querymail= mysql_query($sqlmail);

$checkmailcount = mysql_num_rows($querymail);

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/haxorwar/public_html/includes/mailcount.php on line 21

Link to comment
https://forums.phpfreaks.com/topic/140269-new-to-php-noob-question/
Share on other sites

yea well kinda  let me try to use another table that i know works  hold on

 

oh btw heres my table  if you wanna check it out

 

CREATE TABLE IF NOT EXISTS `messages` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(255) default NULL,
  `message` text NOT NULL,
  `from` int(11) NOT NULL,
  `to` int(11) NOT NULL,
  `from_viewed` tinyint(1) NOT NULL default '0',
  `to_viewed` tinyint(1) NOT NULL default '0',
  `from_deleted` tinyint(1) NOT NULL default '0',
  `to_deleted` tinyint(1) NOT NULL default '0',
  `from_vdate` datetime default NULL,
  `to_vdate` datetime default NULL,
  `from_ddate` datetime default NULL,
  `to_ddate` datetime default NULL,
  `created` datetime NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=28 ;

--
-- Dumping data for table `messages`
--

INSERT INTO `messages` (`id`, `title`, `message`, `from`, `to`, `from_viewed`, `to_viewed`, `from_deleted`, `to_deleted`, `from_vdate`, `to_vdate`, `from_ddate`, `to_ddate`, `created`) VALUES
(27, 'maybe', 'nope', 3, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, '2009-01-10 06:01:31'),
(26, 'oh', 'damn', 3, 3, 0, 0, 0, 0, NULL, NULL, NULL, NULL, '2009-01-10 05:54:48'),
(23, 'nope', 'no cookies for you', 3, 3, 0, 1, 0, 1, NULL, '2009-01-10 05:42:37', NULL, '2009-01-10 05:43:17', '2009-01-10 05:41:25'),
(24, 'test', 'test', 11, 3, 0, 1, 0, 1, NULL, '2009-01-10 05:42:16', NULL, '2009-01-10 05:50:24', '2009-01-10 05:42:09'),
(25, 'Re: test', '[quote]test[/quote]\r\n\r\ndid my quote work', 3, 11, 0, 1, 0, 1, NULL, '2009-01-10 05:43:43', NULL, '2009-01-10 05:50:37', '2009-01-10 05:42:32'),
(22, 'hi', 'test?', 3, 3, 0, 1, 0, 1, NULL, '2009-01-10 05:34:05', NULL, '2009-01-10 05:43:25', '2009-01-10 05:33:46'),
(21, 'hey', 'whatsup', 0, 3, 0, 1, 0, 1, NULL, '2009-01-10 05:42:11', NULL, '2009-01-10 05:42:14', '2009-01-10 05:29:31');

This is very odd I have created your table and populated it and run this code:

 

require('db.php');

$query = mysql_query("SELECT * FROM messsages");
$checkmailcount = mysql_num_rows($query);

 

and I get the same error as you but if I change the table in the query it works fine??

here's the table structure I used:

 

CREATE TABLE IF NOT EXISTS `messages` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(255) default NULL,
  `message` text NOT NULL,
  `from` int(11) NOT NULL,
  `to` int(11) NOT NULL,
  `from_viewed` tinyint(1) NOT NULL default '0',
  `to_viewed` tinyint(1) NOT NULL default '0',
  `from_deleted` tinyint(1) NOT NULL default '0',
  `to_deleted` tinyint(1) NOT NULL default '0',
  `from_vdate` datetime default NULL,
  `to_vdate` datetime default NULL,
  `from_ddate` datetime default NULL,
  `to_ddate` datetime default NULL,
  `created` datetime NOT NULL,
  PRIMARY KEY  (`id`)
);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.