BRabbit Posted November 24, 2011 Report Share Posted November 24, 2011 (edited) Sveiki. Tātad es meiģinu dabūt iekš datubāzes uzrakstīto informāciju, bet nekas nesanāk, un nekādu erroru ari nav! :( Esmu jauniņais @ PHP! :D Kodi: form.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="lv"> <head> <meta charset="utf-8" /> <meta name="keywords" content="huh.lv, help, forum, php, css, html, psd, js. skripti" /> <meta name="description" content="HUH.LV - Help forum, join us" /> <title>HUH.LV - Help forum</title> <link rel="stylesheet" href="style_css/main_style.css" /> <link rel="stylesheet" href="style_css/menu_style.css" /> </head> <body> <form name="post news" action="insert.php" method="post"> Title: <input type="text" name="title" /> Text: <input type="text" name="text" /> <input type="submit" name="Submit" value="SUBMIT" /> </form> </body> </html> insert.php <? include('connect.php'); $query = "INSERT INTO news(title, text)VALUES('".$_POST['title']."','".$_POST['text']."', now())"; mysql_query($query); ?> connect.php <?php $connect = mysql_connect('localhost','user','12345') or die(mysql_error()); $select_db = mysql_select_db('home', $connect) or die (mysql_error()); $result = mysql_query('SELECT * FROM news ORDER BY id') or die(mysql_error()); $row = mysql_fetch_array($result) or die(mysql_error()); ?> Edited November 24, 2011 by BRabbit Quote Link to comment Share on other sites More sharing options...
briedis Posted November 24, 2011 Report Share Posted November 24, 2011 Kļūdu ziņojumi ieslēgti? Quote Link to comment Share on other sites More sharing options...
viena tante Posted November 24, 2011 Report Share Posted November 24, 2011 pirmkārt, Tu gribi ievietot 3 vērtības 2 kolonās Quote Link to comment Share on other sites More sharing options...
Maris-S Posted November 24, 2011 Report Share Posted November 24, 2011 Tev kļūda vaicājumā, Tu norādi divas kolonas: title un text, bet ievietot centies trīs, liekot klāt vēl now(). Nav izveidota eskeipošana, tāpēc nevarēsi ievietot rezervētus simbolus, piemēram apostrofu, vienlaicīgi tas ir arī nedroši. Paskaties šo mysql_real_escape_string un pameklē googlē "sql injection". Quote Link to comment Share on other sites More sharing options...
reiniger Posted November 24, 2011 Report Share Posted November 24, 2011 insert.php <? include('connect.php'); $query = "INSERT INTO news(title, text, XXX )VALUES('".$_POST['title']."','".$_POST['text']."', now())"; mysql_query($query); ?> xxx vieta tavs datuma lauka nosaukums. Quote Link to comment Share on other sites More sharing options...
daGrevis Posted November 25, 2011 Report Share Posted November 25, 2011 Šis ir labi formulēts jautājums. Plusiņš autoram. (: 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.