keissfootball Posted April 15, 2005 Report Share Posted April 15, 2005 Kāds nevar paskaidrot kāpēc man šī kļūda rādās? Parse error: parse error in /user/maja/abc/viesugramata.php on line 84 Link to comment Share on other sites More sharing options...
Kavacky Posted April 15, 2005 Report Share Posted April 15, 2005 Kļūda radās, jo tu esi nepareizi kodu sarakstījis. Kas, es kautkāds brīnumdaris, ka izgudrošu, kas ir tā tava 84. rinda? Link to comment Share on other sites More sharing options...
keissfootball Posted April 15, 2005 Author Report Share Posted April 15, 2005 PHP kods 83 VALUES 84 (\'\',' 85 . '\'' . $name . '\',' 86 . '\'' . $email . '\',' 87 . '\'' . $comments . '\',' 88 . '\'' . $submitted_on . '\' 89 )'; Apmēram tāds kods tas ir Link to comment Share on other sites More sharing options...
Kavacky Posted April 15, 2005 Report Share Posted April 15, 2005 Kas tā par debīlu dalīšanu rindiņās? :blink: Link to comment Share on other sites More sharing options...
Klez Posted April 15, 2005 Report Share Posted April 15, 2005 apmeeram taads. nu jaasaka lol. kaa mees varam zinaat kas tew tur sarakstiits???? Link to comment Share on other sites More sharing options...
keissfootball Posted April 15, 2005 Author Report Share Posted April 15, 2005 // Part One - Initiate a mySQL Database Connection // Database Connectivity Variables and other Variables $DBhost = "localhost"; // Database Server $DBuser = "user"; // Database User $DBpass = "password"; // Database Pass $DBName = "db_1"; // Database Name $table = "viesu_gramata"; // Database Table $numComments = 10; // Number of Comments per page // Connect to mySQL Server $DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error in GuestBook Application: " . mysql_error()); // Select mySQL Database mysql_select_db($DBName, $DBConn) or die("Error in GuestBook Application: " . mysql_error()); // Part Two - Choose what action to perform $action = $_GET['action']; switch($action) { case 'read' : // Fetch all comments from database table $sql = 'comments' . $table . 'guestbook'; $allComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error()); $numallComments = mysql_num_rows($allComments); // Fetch page-wise comments from database table $sql .= 'comments' . $_GET['NumLow'] . ', ' . $numComments; $fewComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error()); $numfewComments = mysql_num_rows($fewComments); // Generate Output for Flash to Read print '&totalEntries=' . $numallComments . '&'; print "<br>&entries="; if($numallComments == 0) { print "No entries in the guestbook, as yet.."; } else { while ($array = mysql_fetch_array($fewComments)) { $name = mysql_result($fewComments, $i, 'name'); $email = mysql_result($fewComments, $i, 'email'); $comments = mysql_result($fewComments, $i, 'comments'); $time = mysql_result($fewComments, $i, 'time'); print '<b>Name: </b>' . $name . '<br><b>Email: </b>' . $email . '<br><b>Comments: </b>' . $comments . '<br><i>Date: ' . $time . '</i><br><br>'; $i++; } } // Print this only when there aren't any more entries.. if($_GET['NumLow'] > $numallComments) { print 'No More Entries!&'; } break; case 'write' : // Recieve Variables From Flash $name = ereg_replace("&", "%26", $_POST['yourname']); $email = ereg_replace("&", "%26", $_POST['youremail']); $comments = ereg_replace("&", "%26", $_POST['yourcomments']); $submit = $_POST['submit']; // Current system date in yyyy-mm-dd format $submitted_on = date ("Y-m-d H:i:s",time()); // Check if its submitted from Flash if($submit == 'Yes'){ // Insert the data into the mysql table $sql = 'INSERT INTO ' . $table . 'guestbook'; ' (`ID`, `name`, `email`, `comments`, `time` ) VALUES (\'\',' . '\'' . $name . '\',' . '\'' . $email . '\',' . '\'' . $comments . '\',' . '\'' . $submitted_on . '\' )'; $insert = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error()); } ?> Varbūt būs kaut kas saprotams, ja es visu skriptu ielikšu? Tā rindiņa - pie beigām ir tā pati, ko rakstīju agrāk!!! Link to comment Share on other sites More sharing options...
Kavacky Posted April 15, 2005 Report Share Posted April 15, 2005 (edited) Un mums tagad jāskaita rindiņas? Ja kaut ko liec, tad liec iekš paste.php.lv. Edited April 15, 2005 by Kavacky Link to comment Share on other sites More sharing options...
bubu Posted April 15, 2005 Report Share Posted April 15, 2005 Šito penteri: $sql = 'INSERT INTO ' . $table . 'guestbook'; ' (`ID`, `name`, `email`, `comments`, `time` ) VALUES (\'\',' . '\'' . $name . '\',' . '\'' . $email . '\',' . '\'' . $comments . '\',' . '\'' . $submitted_on . '\' )'; aizstāj ar šo: $sql = "INSERT INTO guestbook ". "(`ID`, `name`, `email`, `comments`, `time`) VALUES ". "('','$name', '$email', '$comments', '$submitted_on')"; (nav īsti skaidrs kurā tabulā vajag likt datus. Vai nu guestbook, vai $table. Ja pēdējā, tad aizstāj to guestbook ar tekstu $table) Link to comment Share on other sites More sharing options...
keissfootball Posted April 16, 2005 Author Report Share Posted April 16, 2005 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <? // Part One - Initiate a mySQL Database Connection // Database Connectivity Variables and other Variables $DBhost = "mans_hosts"; // Database Server $DBuser = "mans_lietotajvards"; // Database User $DBpass = "mana_parole"; // Database Pass $DBName = "mans_datubazes_vards"; // Database Name $table = "guestbook"; // Database Table $numComments = 10; // Number of Comments per page // Connect to mySQL Server $DBConn = mysql_connect("mans_hosts","mans_lietotajvards","mana_parole") or die("Error in GuestBook Application: " . mysql_error()); // Select mySQL Database mysql_select_db("mans_datubazes_vards") or die("Error in GuestBook Application: " . mysql_error()); // Part Two - Choose what action to perform $action = $_GET['action']; switch($action) { case 'read' : // Fetch all comments from database table $sql = 'SELECT * FROM comments' . $table . 'guestbook'; $allComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error()); $numallComments = mysql_num_rows($allComments); // Fetch page-wise comments from database table $sql .= ' ORDER BY `time` DESC LIMIT ' . $_GET['NumLow'] . ', ' . $numComments; $fewComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error()); $numfewComments = mysql_num_rows($fewComments); // Generate Output for Flash to Read print '&Kopējais ierakstu skaits=' . $numallComments . '&'; print "<br>&Ieraksti="; if($numallComments == 0) { print "Viesu grāmatā nav ziņu"; } else { while ($array = mysql_fetch_array($fewComments)) { $name = mysql_result($fewComments, $i, 'Vārds'); $email = mysql_result($fewComments, $i, 'E-pasts'); $comments = mysql_result($fewComments, $i, 'Komentāri'); $time = mysql_result($fewComments, $i, 'Laiks'); print '<b>Vārds: </b>' . $name . '<br><b>E-pasts: </b>' . $email . '<br><b>Komentāri: </b>' . $comments . '<br><i>Datums: ' . $time . '</i><br><br>'; $i++; } } // Print this only when there aren't any more entries.. if($_GET['NumLow'] > $numallComments) { print 'Nav vietas jaunām ziņām!&'; } break; case 'write' : // Recieve Variables From Flash $name = ereg_replace("&", "%26", $_POST['yourname']); $email = ereg_replace("&", "%26", $_POST['youremail']); $comments = ereg_replace("&", "%26", $_POST['yourcomments']); $submit = $_POST['submit']; // Current system date in yyyy-mm-dd format $submitted_on = date ("Y-m-d H:i:s",time()); // Check if its submitted from Flash if($submit == 'Yes'){ // Insert the data into the mysql table $sql = "INSERT INTO guestbook ". "(`ID`, `name`, `email`, `comments`, `time`) VALUES ". "('','$name', '$email', '$comments', '$submitted_on')"; $insert = mysql_query("guestbook") or die("Error in GuestBook Application: " . mysql_error()); print "&gb_status=Paldies par ierakstīto ziņu.&done=yes&"; return; } print "&_root.write.gb_status=Kļūda!&"; break; } ?> ŠIS IR KODS PILNĪBĀ, PRTOTAMS, BEZ PAROLĒM U.T.T., BET PĀRĒJAIS VISS TAS PATS, KAS ORIĢINĀLĀ. VAI KĀDS NEVARĒTU PATEIKT, KUR MAN KĻŪDA, BŪŠU ĻOTI PATEICĪGS Link to comment Share on other sites More sharing options...
Kavacky Posted April 16, 2005 Report Share Posted April 16, 2005 Un mums tagad jāskaita rindiņas? Ja kaut ko liec, tad liec iekš paste.php.lv. Būsi ko palaidis garām. Domā, ka kāds grib lasīt visu to gabalu? Link to comment Share on other sites More sharing options...
keissfootball Posted April 16, 2005 Author Report Share Posted April 16, 2005 Varat apskatīties viņu, uzspiežot uz hyperlinka Tas kods Link to comment Share on other sites More sharing options...
smarty Posted April 16, 2005 Report Share Posted April 16, 2005 jau skrienam Link to comment Share on other sites More sharing options...
hu_ha Posted April 16, 2005 Report Share Posted April 16, 2005 par taviem izlecieniem nemaz i negribas tev atbildēt, bet nu varbūt tu sapratīsi savu izgāšanos un kādreiz to nožēlosi (attīecībā uz php->html) 1. vispirms ieliec lapai aiz <? rindiņu error_reporting(E_ALL); 2. pēc tam 35 rindu $sql = 'SELECT * FROM comments' . $table . 'guestbook'; pārveido par echo $sql = 'SELECT * FROM comments' . $table . 'guestbook'; un paskaties ko izvadīs - šo stringu ieliec kādā rīkā kas darbojas ar sql datu bāzi (phpMyAdmin, MySqlCC utt). gribētos teikt ka rezultāts būs šāds, kas nebūt nav sql vaicājums, bet gan parodija par to "SELECT * FROM comments guestbook guestbook" Šī vieta izskatās dīvaina.. 3. print aizvieto ar echo, nafig tev print un tad skaties uz kuru rindu tev met kļūdu, un kas tieši tā ir par kļūdu.. No ētikas viedokļa uz to kodu ir grūti skatīties - manīgo nepārbaudīšana, visa malšana vienā lielā penterī utt.. Link to comment Share on other sites More sharing options...
keissfootball Posted April 16, 2005 Author Report Share Posted April 16, 2005 (edited) Tagad man šāda kļūda rādās, kad izlaboju to visu: Notice: Undefined index: action in /user/maja/abc/guestbook.php on line 30 Vai jūs nevarētu pateikt kas tā pa kļūdu? Kaut kas ar GET 'action' Edited April 16, 2005 by keissfootball Link to comment Share on other sites More sharing options...
bubu Posted April 16, 2005 Report Share Posted April 16, 2005 Tas nozīmē, ka masīvā _GET nav elementa ar atslēgu 'action'. Link to comment Share on other sites More sharing options...
Recommended Posts