krisis32 Posted February 6, 2011 Report Share Posted February 6, 2011 Sveiki. Lieta tāda ka netieku galā ar mysql_num_rows. Izmet "Query was empty" - Skripts Ja šāds lietotājs pastāv tad updeitojam viņa punktus +1 , bet ja nav tāda lietotāja tad ievietojam viņu! Quote Link to comment Share on other sites More sharing options...
Rincewind Posted February 6, 2011 Report Share Posted February 6, 2011 INSERT INTO tabtest ('punkti' , 'niks') VALUES ('0' , 'liettest') ON DUPLICATE KEY UPDATE punkti=punkti+1 Quote Link to comment Share on other sites More sharing options...
sandis_m Posted February 6, 2011 Report Share Posted February 6, 2011 Tas mysql_num_rows() nav tāds baigi rijīgs, uz datubāzes noslodzi? Quote Link to comment Share on other sites More sharing options...
Rincewind Posted February 6, 2011 Report Share Posted February 6, 2011 Tas mysql_num_rows() nav tāds baigi rijīgs, uz datubāzes noslodzi? mysql_num_rows() rāda cik rindas ir atgrieztajā rezultātā, nekādas datubāzes viņu neinteresē. Quote Link to comment Share on other sites More sharing options...
yeahz Posted February 6, 2011 Report Share Posted February 6, 2011 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()); Quote Link to comment Share on other sites More sharing options...
marcis Posted February 6, 2011 Report Share Posted February 6, 2011 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. Quote Link to comment Share on other sites More sharing options...
daGrevis Posted February 6, 2011 Report Share Posted February 6, 2011 Skarbi pateikts. xD Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.