Jump to content
php.lv forumi

mysql_num_rows nekorekti uzvedās


Pentiums

Recommended Posts

Labvakar.

Problēmiņa ar PHP fju mysql_num_rows. Met ārā:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/index.php on line 31

 

Kods te:

$query = mysql_query("SELECT * FROM invites WHERE id = 1 AND to = 1 AND from = 9");
if(mysql_num_rows($query) != 0) {

...

}

 

DB tabula te:

CREATE TABLE `invites` (
 `id` int(11) NOT NULL auto_increment,
 `to` int(11) NOT NULL,
 `from` int(11) NOT NULL,
 `date` varchar(10) collate utf8_latvian_ci NOT NULL,
 `text` text collate utf8_latvian_ci NOT NULL,
 PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_latvian_ci;

Edited by Pentiums
Link to comment
Share on other sites

$query = mysql_query("SELECT * FROM invites WHERE id = 1 AND to = 1 AND from = 9") or die(mysql_error());

es parasti rakstu if(mysql_num_rows($query) > 0) bet tas buutiibu nemaina

if(mysql_num_rows($query) != 0) {

 

...

 

}

Edited by Klez
Link to comment
Share on other sites

pamegjini to kveriju iebarot Pa taisno DB ( caur consoli vai PhpMyAdmin ).. tad redzeesi kas un kaa..

Bet vispar labaak atteikties no taadiem lauku nosaukumiem kaa TO FROM IF utt .. iespejams kaa tieshi taa ir problema ...

-> pamegjini vinjus (lauku nosaukumus ielikt starp ( ` ) ...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...