Jump to content
php.lv forumi

Query was empty


krisis32

Recommended Posts

Tev jau ir kverijs kverijā

 

$select = mysql_query ("SELECT * FROM tabtest WHERE niks='liettest'") or die(mysql_error());
if ( $num_rows = mysql_num_rows($select) )
{
echo "Atrasti $num_rows ieraksti";
echo'Fails updeitots';

$ieliekam = "UPDATE tabtest SET punkti=punkti+1 WHERE niks='liettest'";
}
else
{

$ieliekam="INSERT INTO tabtest ('punkti' , 'niks') VALUES ('0' , 'liettest')";
}


$ieliekam = mysql_query ($query) 
or die("Errors: ". mysql_error());

Link to comment
Share on other sites

Sāksim ar to, ka "Query was empty" kļūdu met 17. rindā esošais mysql_error(), nevis mysql_num_rows()... 16. rindā tu mysql_query() funkcijai padod nedefinēto mainīgo $query. Izskatās, ka $query vietā būtu bijis jābūt $ieliekam mainīgajam, taču mainīgā tips gan nedrīkstētu svārstīties starp string un resource. Kad būsi ticis galā ar php pusi, varēsi ķerties klāt sql kļūdu labošanai, jo tādas arī tur ir novērojamas.

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...