Forbidden Posted February 4, 2005 Report Share Posted February 4, 2005 Oi, atvainojos - reku ir <?php $mysqli = new mysqli('hosts','users','pass'); $mysqli -> select_db('index'); $result = $mysqli->query("SELECT * FROM teible ORDER BY id DESC"); while($row = $result->fetch_assoc()) { print $row['1'] . ' <br/> ' . $row['2'] . '<br/>'.'<br>'; } $result->close(); ?> Link to comment Share on other sites More sharing options...
hmnc Posted February 4, 2005 Report Share Posted February 4, 2005 pirms ķerties pie datubāzēm iesaku KAUT NEDAUDZ palasīt par tām. kā tur viss notiek, etc. + tā mysql classe izskatās pēc varianta: function echo_text($text) { echo $text; } Link to comment Share on other sites More sharing options...
bubu Posted February 5, 2005 Report Share Posted February 5, 2005 (edited) pirms ķerties pie datubāzēm iesaku KAUT NEDAUDZ palasīt par tām. kā tur viss notiek, etc. + tā mysql classe izskatās pēc varianta: 13394[/snapback] Tā mysqli klase ir standarta PHP5 klase, ja kas.. Ka tik tev ne pašam ir jāpalasa php manuālis :) (http://lv.php.net/manual/en/ref.mysqli.php#mysqli.classes) Edited February 5, 2005 by bubu Link to comment Share on other sites More sharing options...
Forbidden Posted February 7, 2005 Report Share Posted February 7, 2005 Ņāā atkal esmu nonācis strupceļā, un ceru uz jūsu palīdzību, jo pats netieku galā :). Jautājums i šāds: Kur īsti man te ir tā šitā kļūda: Warning: mysqli_query() expects at least 2 parameters, 1 given in c:\web\test\gb.php on line 8 ??? Izmēģināju viskko, nestrādā <?php if($_POST['submit']) { $mysqli = new mysqli('host','user','pass'); $mysqli->select_db('index'); $sql[addpost] = mysqli_query("INSERT INTO guestbook (name, email, message, date) VALUES ('$_POST[name]','$_POST[email]','$_POST[message]',time())"); mysqli_close($mysqli); echo "Thanks ".$_POST['name']." your message has been added\n"; } ?> Nu šī ir 8. rindiņa: $sql[addpost] = mysqli_query("INSERT INTO guestbook (name, email, message, date) VALUES ('$_POST[name]','$_POST[email]','$_POST[message]',time())"); Link to comment Share on other sites More sharing options...
рпр Posted February 7, 2005 Report Share Posted February 7, 2005 vispaar jau tur skaidri un gaishi rakstiits, ka tev nepareizs parametru skaits. Link to comment Share on other sites More sharing options...
bubu Posted February 7, 2005 Report Share Posted February 7, 2005 Tu angļu valodu saproti? Warning: mysqli_query() expects at least 2 parameters, 1 given in c:\web\test\gb.php on line 8 ??? Latviski tas nozīme: mysqli_query() sagaida vismaz 2 parametrus, bet iedots tikai 1! Skaties šeit kādi parametri jānodot mysqli_query() funkcijai: http://lv.php.net/mysqli_query Eh... kad reiz beidzot cilvēki iemācīsies lasīt kļūdu paziņojumus... Link to comment Share on other sites More sharing options...
Forbidden Posted February 7, 2005 Report Share Posted February 7, 2005 Nu lai sāktu kaut ko darīt uz datora ir jāsaprot angļu val., bet es nesaprotu kādu to otro parametru vajadzētu... ok tagad palasīšu... Link to comment Share on other sites More sharing options...
bubu Posted February 7, 2005 Report Share Posted February 7, 2005 Tak piemērus paskaties manuālī! Link to comment Share on other sites More sharing options...
Forbidden Posted February 7, 2005 Report Share Posted February 7, 2005 (edited) HTML: <form method="post" action="gb.php"> <table cellpadding="6" cellspacing="0"> <tr> <td>Vвrds :</td> <td><input type="text" name="name" /></td> </tr> <tr> <td>E-Mails :</td> <td><input type="text" name="email" /></td> </tr> <tr> <td valign="top">Ziņa:</td> <td><textarea name="message" cols="30" rows="6"></textarea></td> </tr> <tr> <td> </td> <td> <input type="submit" name="submit" value="Piemзslot" /> <input type="reset" name="reset" value="Ne-Piemзslot" /> </td> </tr> </table> </form> PHP: <?php if($_POST['submit']) { $mysqli = new mysqli('localhost','root','074'); $mysqli->select_db('index'); $result = $mysqli->query("SELECT * FROM guestbook ORDER BY id DESC"); while($row = $result->fetch_assoc()) { print '<p>' . $row['name'] . ' <br/> ' . $row['message'] . '<br/>'.'<br>'.'</p>'; } $result->close(); $sql[addpost] = mysqli_query($mysqli, "INSERT INTO guestbook (name, email, message, date) or die(mysqli_errno()'. : .'mysqli_error()); VALUES ('$_POST[name]','$_POST[email]','$_POST[message]',time())"); mysqli_close($mysqli); echo "Paldies, ".$_POST['name']." Jыsu ieraksts ir pievienots\n"; } ?> Nu neiet, vinjsh nepievieno ierakstus DB, izmeegjinaaju visu ko, nekaadu eroru aaraa nemet, ilgi un dikti jau sezhu - neiet..... arii manuaalii tajaa lv.php.net/manual/en neko neatradu kas man palidzetu :( prasishu gudraakiem, kads var paliidzeet izprast kas te iisti ir pa kljuudu ka nepievieno db??? Edited February 8, 2005 by Forbidden Link to comment Share on other sites More sharing options...
Kristabs Posted February 11, 2005 Report Share Posted February 11, 2005 (edited) Neko netesteeju, bet manupraat shitam vajadzeetu iet, ja tev ar teiblu viss ok. viesugraamata.php: <p><h1>Es miilu Kristabs</h1></p> <form method="post" action="gb.php"> <table cellpadding="6" cellspacing="0"> <tr> <td>Vвrds :</td> <td><input type="text" name="name" /></td> </tr> <tr> <td>E-Mails :</td> <td><input type="text" name="email" /></td> </tr> <tr> <td valign="top">Ziņa:</td> <td><textarea name="message" cols="30" rows="6"></textarea></td> </tr> <tr> <td> </td> <td> <input type="submit" name="submit" value="Piemзslot" /> <input type="reset" name="reset" value="Ne-Piemзslot" /> </td> </tr> </table> </form> <?php $hostname="localhost"; $mysql_login="root"; $mysql_password="074"; $database="index"; if (!($db = mysql_connect("$hostname", "$mysql_login" , "$mysql_password"))) { print("Nav konekcijas ar mysql vai kkas taads."); } else { if (!(mysql_select_db("$database",$db))) { print("nevar atrast DB."); } } $query = "SELECT * FROM guestbook"; $result = mysql_query($query); echo "<b>Mani vienreizeejie ieraksti viesu graamataa:</b><br><br>"; while ($row = mysql_fetch_array($result)) { echo "<a href='mailto:$row['email']'><b>$row['name']</b></a><br>$row['message']\n"; echo date('d.m.Y. H:i', $row['date']); } ?> gb.php: <?php $hostname="localhost"; $mysql_login="root"; $mysql_password="074"; $database="index"; if (!($db = mysql_connect("$hostname", "$mysql_login" , "$mysql_password"))) { print("Nav konekcijas ar mysql vai kkas taads."); } else { if (!(mysql_select_db("$database",$db))) { print("nevar atrast DB."); } } $name = htmlspecialchars($_POST['name'], ENT_QUOTES); $email = htmlspecialchars($_POST['email'], ENT_QUOTES); $message = wordwrap($_POST['message'], 55, ' ', 1); $message = htmlspecialchars($kmessage, ENT_QUOTES); $date = mktime(); if ($name && $message) { @mysql_query("INSERT INTO guestbook values(0, '$name', '$email', '$message', '$date')") or die(EJ BETONEET); } //to nulli ieliec pareizajaa vietaa, kura kolona tev peec kaartas ir id, tajaa vietaa arii liec shajaa rindaa header("location: viesugraamata.php"); } ?> Ja iet, tad no tevis alinsh. Edited February 11, 2005 by Kristabs Link to comment Share on other sites More sharing options...
bubu Posted February 11, 2005 Report Share Posted February 11, 2005 HTML:...[right][snapback]13486[/snapback][/right] Kļūdas nekādas nerāda? error_reporting(E_ALL); ieslēgts? display_errors=On?? Link to comment Share on other sites More sharing options...
Forbidden Posted February 19, 2005 Report Share Posted February 19, 2005 (edited) jau atkal griežos pēc palīdzības pie jums. Laikam vel mazliet un mani vairs te neieredzēs ne ar acu galu... Nu ka nepievieno DB, ta nepievieno, nedalec man :( <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table cellpadding="6" cellspacing="0"> <tr> <td>Vвrds :</td> <td><input type="text" name="name" /></td> </tr> <tr> <td>E-Mails :</td> <td><input type="text" name="email" /></td> </tr> <tr> <td valign="top">Ziтa:</td> <td><textarea name="message" cols="30" rows="6"></textarea></td> </tr> <tr> <td> </td> <td> <input type="submit" name="$_POST[submit]" value="Piemзslot" /> <input type="reset" name="reset" value="Ne-Piemзslot" /> </td> </tr> </table> </form> <?php error_reporting(E_ALL); if($_POST['submit']) { $mysqli = new mysqli('host','usr','pass'); $mysqli->select_db('index'); $result = $mysqli->query("SELECT * FROM guestbook ORDER BY id DESC"); while($row = $result->fetch_assoc()) { print '<p>' . $row['name'] . ' <br/> ' . $row['message'] . '<br/>'.'<br>'.'</p>'; } $result->close(); $sql['addpost'] = mysqli_query($mysqli, "INSERT INTO guestbook (name, email, message, date) or die(mysqli_errno()'. : .'mysqli_error()); VALUES ('$_POST[name]','$_POST[email]','$_POST[message]',time())"); mysqli_close($mysqli); echo "Paldies, ".$_POST['name']." Jыsu ieraksts ir pievienots\n"; } ?> Ieliku ari HTML jo laikam kautko ne taa esmu salicis. Nu lieta tada ka name, email, message jams saprot kaa nodefineetus, bet submit nee :( kas par vainu? Edited February 19, 2005 by Forbidden Link to comment Share on other sites More sharing options...
Lynx Posted February 19, 2005 Report Share Posted February 19, 2005 Es rakstitu shadi: <?php error_reporting(E_ALL); if(!isset($_GET['darbiba'])) { echo' <form method="post" action="$_SERVER['PHP_SELF']?darbiba=pievienot> ... nak parejais, html kods <input type="submit" name="submit" value="Piemзslot" /> <input type="reset" name="reset" value="Ne-Piemзslot" /> </td> </tr> </table> </form>'; elseif($_GET['darbiba'] == 'pievienot') { $mysqli = new mysqli('host','usr','pass'); $mysqli->select_db('index'); $result = $mysqli->query("SELECT * FROM guestbook ORDER BY id DESC"); while($row = $result->fetch_assoc()) { print '<p>' . $row['name'] . ' <br/> ' . $row['message'] . '<br/>'.'<br>'.'</p>'; } $result->close(); $sql['addpost'] = mysqli_query($mysqli, "INSERT INTO guestbook (name, email, message, date) or die(mysqli_errno()'. : .'mysqli_error()); VALUES ('$_POST[name]','$_POST[email]','$_POST[message]',time())"); mysqli_close($mysqli); echo "Paldies, ".$_POST['name']." Jыsu ieraksts ir pievienots\n"; } ?> Neesmu testejis, bet vajadzetu stradat. Pats shadu variantu lietoju. Iespejams ka ir efektivaki varianti, bet tur varetu kadi profesionalaki koderi palidzet... Link to comment Share on other sites More sharing options...
bubu Posted February 19, 2005 Report Share Posted February 19, 2005 Pag, es nesaprotu: vai tad šitais ir sintaktiski korekts (izpildoties neizmet nekādu kļūdas paziņojumu?) $sql['addpost']= mysqli_query($mysqli, "INSERT INTO guestbook (name, email, message, date) or die(mysqli_errno()'. : .'mysqli_error()); VALUES ('$_POST[name]','$_POST','$_POST[message]',time())"); Manuprāt tur absolūts sviests. Link to comment Share on other sites More sharing options...
alins Posted February 20, 2005 Report Share Posted February 20, 2005 $pievieno = mysqli_query($mysqli, "INSERT INTO guestbook (name, email, message, date) VALUES ('$_POST[name]','$_POST','$_POST[message]',time())"); pameegjini shita vai vispaar iet!!! Link to comment Share on other sites More sharing options...
Recommended Posts