yeahz Posted January 26, 2010 Report Posted January 26, 2010 Esmu sācis mācīties Ajax un man te kaut kas nesanāk. Kods: http://paste.php.lv/48c21b2f980a1d669e6a298549dc3738?lang=javascript un <!-- Verify if user exists for login --> <?php include("include/header.php"); if(isset($_GET['name'])){ $namez= mysql_real_escape_string($_GET['name']); $insertSite_sql = "INSERT INTO categories (name) VALUES ($namez)"; $insertSite= mysql_query($insertSite_sql) or die(mysql_error()); //<!-- If is set URL variables and insert is ok, show the site name --> echo $namez; } else { echo 'Error! Please fill all fileds!'; } headerī.php notiek piekonektēšanās pie db. Vienmēr, kad kaut ko ierakstu, izmet: Unknown column 'Celtniecība' in 'field list' tabulas struktūra: CREATE TABLE `categories` ( `id` int(11) NOT NULL auto_increment, `name` varchar(255) collate utf8_latvian_ci NOT NULL, `main_category` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_latvian_ci AUTO_INCREMENT=5 ; Quote
2easy Posted January 26, 2010 Report Posted January 26, 2010 (edited) kļūdai nav nekāda sakara ar ajax ;) $namez= "'" . mysql_real_escape_string($_GET['name']) . "'"; vērtības priekš varchar laukiem sqlā padod kā tekstu, kas ir ielikts apostrofos Edited January 26, 2010 by 2easy Quote
yeahz Posted January 26, 2010 Author Report Posted January 26, 2010 Paldies, būšu šo palaidis garām. Quote
anonīms Posted January 27, 2010 Report Posted January 27, 2010 A nav labāk izmantot jquery? Tad būs mazāk rindiņas ^^ $.post(..); Quote
rATRIJS Posted January 27, 2010 Report Posted January 27, 2010 Cik nu mazak - paskaties cik jQuery ir rindinu :) jQuery ir verts likt, ja ir paliels uzsvars uz AJAX lapa un/vai tiek izmantotas visadas DOM manipulacijas n stuff. Turpretim, ja tikai viena vieta ir mazins AJAX'ins, tad jQuery ir overkill... Quote
2easy Posted January 27, 2010 Report Posted January 27, 2010 true uzrakstīt savu httpPost() funkciju ir dažas rindiņas, bet jquery ir ~56KB Quote
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.