Jump to content

zirgs

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Everything posted by zirgs

  1. Hi. I have very simple question about mysql ... can someone tell me function that checks if query was successfull? or just use somth like that? [code] if (!$query) { echo "Not good ;("; } ) [/code]
  2. hello, can anyone can give me some clue how to restrict posting codes(html's,js's,php's) and so on, i mean in guestbooks and like that. thanks.
  3. ok it didn't work for me what i wanted .... ok anyone knows how to check if form was submited or not (i mean if submit button was pressed) ... any help?
  4. ok i'll try it out later.thanks.
  5. hi there i'm using this code [code] <?php if ( $_POST['author']=="name" || $_POST['comment']=="comment" ) { if (isset($_POST)) { echo "Some fields were left blank!"; } } elseif ( $_POST['author']=="" || $_POST['comment']=="" ) { if (!isset($_POST)) { echo "Some fields were left blank!"; } } else { include 'db_connect.php'; $date = date('d/m/Y G:i'); $query="INSERT INTO comments (newid,author,comment,date) VALUES ('$_POST[id]','$_POST[author]','$_POST[comment]','$date')"; if(mysql_db_query($current_db,$query)) { echo "Comment added!"; mysql_close($database); } } ?> [/code] it works fine until i press submit when there isn't anything writen into fields.I need to then show "Some fields were left blank!" anyone help ? what i'm doing wrong?thanks.
  6. thanks, [b]wildteen88[/b]. I've just modified it a bit because there was one error ... but now my problem is solved. cheers! [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
  7. ok i'll make it "more english" [code] <?php include 'db_con.php'; $numb = $_GET['numb']; settype($numb,"integer"); if(!empty($_GET['numb'])) { $sql = mysql_query("select * from news where id = '$numb'"); $num = mysql_num_rows($sql); $sql_coments= mysql_query("select * from coments where newsid = '$numb' order by id desc"); if($num == 1) { $row = mysql_fetch_array($sql); $row_coments = mysql_fetch_array($sql_coments); $title = $row["title"]; $date = $row["date"]; $new = $row["new"]; $shortnew = $row["shortnew"]; $author = $row_k["author"]; // coment author $coment = $row_k["coment"]; // coment $comentdate = $row_k["comentdate"]; // date of the coment echo "<span id=virs>"; echo $title; echo "</span><br />"; echo "<span id=dat>"; echo $date; echo "</span><br />"; echo $new; echo "<br /><br /><br /><br /><br />"; while($row_coments = mysql_fetch_array($sql_coments)) { echo "<span id=au>"; echo $author; echo "</span><br />"; echo "<span id=dat>"; echo $comentdate; echo "</span><br />"; echo $coment; echo "<br /><br />"; } } } if(empty($_GET['numb']) OR $num <> 1) { $sql = mysql_query("select * from zinjas order by id desc"); while($row = mysql_fetch_array($sql)) { echo "<span id=virs><a href=zinjas.php?numb="; echo $row["id"]; echo ">"; echo $row["title"]; echo "</a></span><br />"; echo "<span id=dat>"; echo $row["date"]; echo "</span><br />"; echo $row["shortnew"]; echo "<br /><br />"; echo "<div class=komentari>"; echo "<a href=zinjas.php>Coments</a>"; echo "</div>";    } } ?> [/code] now you should understand which part is coment part ... any solutions?
  8. change [code] echo $row[0]; [/code] to this one [code] echo $row['0']; [/code] but i think that you cant echo non existing row?
  9. Ok i changed my code to this one: [code] <?php include 'db_con.php'; $numb = $_GET['numb']; settype($numb,"integer"); if(!empty($_GET['numb'])) { $sql = mysql_query("select * from news where id = '$numb'"); $num = mysql_num_rows($sql); $sql_k = mysql_query("select * from komentari where zinjuid = '$numb' order by id desc"); if($num == 1) { $row = mysql_fetch_array($sql); $row_k = mysql_fetch_array($sql_k); $t = $row["t"]; $d = $row["d"]; $n = $row["n"]; $iz = $row["iz"]; $au = $row_k["au"]; $co = $row_k["co"]; $cod = $row_k["cod"]; echo "<span id=virs>"; echo $t; echo "</span><br />"; echo "<span id=dat>"; echo $d; echo "</span><br />"; echo $n; echo "<br /><br /><br /><br /><br />"; while($row_k = mysql_fetch_array($sql_k)) { echo "<span id=au>"; echo $au; echo "</span><br />"; echo "<span id=dat>"; echo $cod; echo "</span><br />"; echo $co; echo "<br /><br />"; } } } if(empty($_GET['numb']) OR $num <> 1) { $sql = mysql_query("select * from zinjas order by id desc"); while($row = mysql_fetch_array($sql)) { echo "<span id=virs><a href=zinjas.php?numb="; echo $row["id"]; echo ">"; echo $row["t"]; echo "</a></span><br />"; echo "<span id=dat>"; echo $row["d"]; echo "</span><br />"; echo $row["iz"]; echo "<br /><br />"; echo "<div class=komentari>"; echo "<a href=zinjas.php>Komentari</a>"; echo "</div>";    } } ?> [/code] it still echoes out only one comment ... maybe i'm using while in this case wrong? sorry i'm not yet familiar with php where is involved mysql ...
  10. Hello i'm now using this scripts for news display but i need to show each news coments, but with this code i'm having trouble that it shows only 1 coment (but in database is more than one) ... can you help me out? code: [code] <?php include 'db_con.php'; $numb = $_GET['numb']; settype($numb,"integer"); if(!empty($_GET['numb'])) { $sql = mysql_query("select * from news where id = '$numb'"); $num = mysql_num_rows($sql); $sql_k = mysql_query("select * from komentari where zinjuid = '$numb' order by id desc"); if($num == 1) { $row = mysql_fetch_array($sql); $row_k = mysql_fetch_array($sql_k); $t = $row["t"]; $d = $row["d"]; $n = $row["n"]; $iz = $row["iz"]; $au = $row_k["au"]; $co = $row_k["co"]; $cod = $row_k["cod"]; echo "<span id=virs>"; echo $t; echo "</span><br />"; echo "<span id=dat>"; echo $d; echo "</span><br />"; echo $n; echo "<br /><br /><br /><br /><br />"; echo "<span id=au>"; echo $au; echo "</span><br />"; echo "<span id=dat>"; echo $cod; echo "</span><br />"; echo $co; echo "<br /><br />"; } } if(empty($_GET['numb']) OR $num <> 1) { $sql = mysql_query("select * from zinjas order by id desc"); while($row = mysql_fetch_array($sql)) { echo "<span id=virs><a href=zinjas.php?numb="; echo $row["id"]; echo ">"; echo $row["t"]; echo "</a></span><br />"; echo "<span id=dat>"; echo $row["d"]; echo "</span><br />"; echo $row["iz"]; echo "<br /><br />"; echo "<div class=komentari>"; echo "<a href=zinjas.php>Komentari</a>"; echo "</div>";    } } ?>[/code]
  11. thanks for the advices i've just realised that it was strupid to first do connection to database and then check for empty fields ... i've made first check and then connection and query ... and no errors [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] cheers!
  12. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] <?php $db_username = "*****"; $db_pasword = "*****"; $db_host = "******"; $db = "news"; @mysql_connect($db_host, $db_username, $db_pasword) or die("Can't connect to database!"); @mysql_select_db($db) or die("Can't select database!"); if ( $_POST['title'] == "" || $_POST['date'] == "" ) ( echo "Some fields were left blank!"; ) elseif ( $_POST['new'] == "" ) ( echo "You didn't entered the new!"; ) else ( $query="INSERT INTO news (title,date,new,short_news) VALUES ('$_POST['title']','$_POST['date']','$_POST['new']','$_POST['short_new']')"; if(!mysql_db_query($db,$query)) die(mysql_error()); echo "News added succesfully!"; ) ?>[/quote]
  13. i thought that it's not obligatory... but it's something in this line i think because it's 12 line [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]echo "Some fields were left blank!";[/quote] sorry for so much questions but i really want to figure it out :)
  14. oh ... [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] ... dumb ass me ... but now i'm getting this error [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] Parse error: parse error, unexpected T_ECHO in G:\www\Apache2\public\admin\add.php on line 12[/quote] no sense to me what is t_echo ... ? any help another time?
  15. Hi there can anyoneplease chek my code and say why php is displaying this error [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: parse error, unexpected '{', expecting '(' in G:\www\Apache2\public\admin\add.php on line 14[/quote] Code: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php $db_username = "*****"; $db_pasword = "*****"; $db_host = "******"; $db = "news"; @mysql_connect($db_host, $db_username, $db_pasword) or die("Can't connect to database!"); @mysql_select_db($db) or die("Can't select database!"); if ( $_POST[title] == "" || $_POST[date] == "" ) { echo "Some fields were left blank!"; } elseif { $_POST[new] == "" } { echo "You didn't entered the new!"; } else { $query="INSERT INTO news (title,date,new,short_news) VALUES ('$_POST[title]','$_POST[date]','$_POST[new]','$_POST[short_new]')"; if(!mysql_db_query($db,$query)) die(mysql_error()); echo "News added succesfully!"; } ?> [/quote] thanks!
  16. you may use : [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] <meta http-equiv="refresh" content="1 url=page.php"> [/quote]
  17. Ouh seems th script doesnt understand the $found argument ... it's just giving out id= and no number ...
  18. Thank you guys another time ... but give me some more help please ... so i wanted how to make with echo function like the title displays like a link to the full new ... like the title has a link like if it's first new then link is news.php?id=1 and so on ... want to make it write by a script ... any help ... it would be very nice i won't disturb you for some time ... :)
  19. Oh thanks a lot guys ... now i understand ... problem was in my english [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] .... now i'm good ... thanks, cheers!
  20. It seems that you didn't got what i wanted ... ok so ... now i'm using this code [code] <?php $id = $_GET['id']; switch($id) {     case '1':          include_once('1.txt');          break;     case '2':          include_once('2.txt');          break;     default: include_once('news.txt'); } ?> [/code] and i want the same but with mysql not .txt files ... but i don't want to write each case'' into the script but make it calculate himself ... if case'' is 1 then select id 1 if case'' is 3098 then select 3098 ... that's what i want ... and if id is wrong then display the default: ... so can you please help with with that ?
  21. any help please ... ? it would be great ...
  22. Hello there, i was coding pretty well till now ... because i can't understand one thing ... so i have some mysql table news and there is some fields like id number and message i was vondering on how to make like the switch script work like that i dont need to write each id in the script but it somehow calculates himselft i mean like if user enters news?id=36 then script shows new from mysql with that id but if the id is incorrect just show the main page for news ... so any help? thanks ....
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.