-=HELLBENDER=- Posted July 15, 2011 Report Share Posted July 15, 2011 $randoms = random_string(); $niks = mysql_real_escape_string($_POST['niks']); $skype = mysql_real_escape_string($_POST['skype']); $nosaukums = mysql_real_escape_string($_POST['nosaukums']); $apraksts = mysql_real_escape_string($_POST['apraksts']); if(mysql_num_rows(mysql_query("SELECT * FROM saraksts WHERE key = '$randoms'"))){ echo "Ieraksts jau eksistē!"; break; } $sql="INSERT INTO saraksts (niks, skype, nosaukums, apraksts, key, ip) VALUES ('$niks', '$skype', '$nosaukums', '$apraksts', '$randoms', '$_SERVER[REMOTE_ADDR]')"; Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in index.php on line 642Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key, ip) VALUES ('asdasdasdasdasd', 'asdasdasdasd', 'asdasdasdasd', 'asdasdasdas' at line 1 Ilgi pētīju, bet nespēju saskatīt kur ir kļūda.. Varbūt kādam ir veiklāka acs? Quote Link to comment Share on other sites More sharing options...
briedis Posted July 15, 2011 Report Share Posted July 15, 2011 Izlasi piesprausto tēmu - http://php.lv/f/topic/15467-warning-mysql-result-supplied-argument-is-not-a-valid-mysql-result-resource/ Tak cilvēki, vajag kādreiz arī palietot iebūvēto meklētāju, pirms bliežam kārtējo šāda veida tematu... Quote Link to comment Share on other sites More sharing options...
-=HELLBENDER=- Posted July 15, 2011 Author Report Share Posted July 15, 2011 (edited) mysql_errors parādīja šo "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key = 'fxg49qzy9yw'' at line 1" (pirmajam) bet nu kā jau teicu, kļūdu tur nespēju saskatīt. Problēma nav gluži tādi pati, kā tajā topikā. Edited July 15, 2011 by -=HELLBENDER=- Quote Link to comment Share on other sites More sharing options...
briedis Posted July 15, 2011 Report Share Posted July 15, 2011 (edited) iespējams KEY ir rezervēts mysql vārds. Mēģini `key` = .. EDIT: Jā, tā ir. http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html Edited July 15, 2011 by briedis Quote Link to comment Share on other sites More sharing options...
-=HELLBENDER=- Posted July 15, 2011 Author Report Share Posted July 15, 2011 Paldies, nomainīju uz randkey un aizgāja. 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.