-
Post overlap
-
Post overlap
Now i dont know if this is simple or hard. If its just css or php code i need But basically i have posting system and users can comment on posts. In the comments page it shows orginal post and one users have left (the comments) I had one in there and this was fine but i added another and it looked like this... As you can see a second comment (hello goodbye) overlaps the first one. I want it so that the 2 (or more) comments are displayed seperate. <div class="message"> <?php $sql = mysql_query("SELECT * FROM threads WHERE id = '". mysql_real_escape_string($_GET['id']) . "'") or die(mysql_error()); while($r = mysql_fetch_array($sql)) { $posted = date("jS M Y h:i",$r['posted']); echo "".$r['author']." $posted"; ?> <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="<?php echo "".$r['message'].""; ?>"> Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> <div class="message2"><?php echo " ".$r['message'].""; ?></div> <?php echo "Likes: ".$r['votes_up']." "; echo "Dislike: ".$r['votes_down'].""; }?> </div> <br/> <hr width="725px"> <?php echo "<h3>Replies...</h3>"; ?> <div class="message"><?php $sql = mysql_query("SELECT * FROM replies WHERE thread = '". mysql_real_escape_string($_GET['id']) . "'") or die(mysql_error()); while($r = mysql_fetch_array($sql)) { $posted = date("jS M Y h:i",$r['posted']); echo "".$r['author']." $posted"; ?> <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="<?php echo "".$r['message'].""; ?>"> Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> <div class="message2"> <?php echo " ".$r['message']."" ; } ?> </div> </div> <hr width="725px"> <form action="newreply.php" method="POST"> Your Name: <input type="text" name="author"> <input type="hidden" value="<?php echo $_GET['id']; ?>" name="thread"><br> Message:<br><textarea cols="60" rows="5" name="message"></textarea><br> <input type="submit" value="Post Reply"> </form> Im sure this is just something im missing or something but i really am clueless! Help? CSS .message { width: 500px; color: black; background: white; padding:8px; border:1px solid white; margin:5px auto; -moz-border-radius:8px; } .message2 { background-color: grey; }
-
max/min characters allowed
This doesnt do anything. I tested it with a short value and text was still inputted to database
-
max/min characters allowed
I was wondering how i could set a max (500) and min (20) characters allowed for my posting/message system. code for this <div class='submit'> <form method="post" action="newthread.php">LAD Name: <input name="author"/><br/>Message:<br/> <textarea rows="5" cols="60" name="message"></textarea><br/> <input value="Post Banter" type="submit"/> </form> </div> PLEASE NOTE I CAN NOT CHANGE 'NAME' AS IT BREAKS MY PHP CODE FOR POSTING TO DATABASE i tried a script i found on net but when i used this it broke my writing to database. So can someone please tell me how i can set max/min characters allowed and to display error message if these are not met
-
post to twitter function
Hello Im looking for a function to post to twitter users posts they make on my website. For example Message: "hello world" [twitter] Click twitter and it posts message along with page URL. If the mesaage is longer than the twitter max then it shows a abbreviated version. I at the momment i have an official one that only posts the whole page to twitter and not an individual post/message Can anyone help how to do this and where to get it?
-
-
Notice: Undefined offset: 0 in
Notice: Undefined offset: 0 in C:\xampp\htdocs\mywebsite\reddit_vote_tut\src\votes.php on line 41 Notice: Undefined offset: 0 in C:\xampp\htdocs\mywebsite\reddit_vote_tut\src\votes.php on line 27 Notice: Undefined offset: 1 in C:\xampp\htdocs\mywebsite\reddit_vote_tut\src\votes.php on line 27 <?php include("config.php"); function getAllVotes($id) { /** Returns an array whose first element is votes_up and the second one is votes_down **/ $votes = array(); $q = "SELECT * FROM entries WHERE id = $id"; $r = mysql_query($q); if(mysql_num_rows($r)==1)//id found in the table { $row = mysql_fetch_assoc($r); $votes[0] = $row['votes_up']; $votes[1] = $row['votes_down']; } return $votes; } function getEffectiveVotes($id) { /** Returns an integer **/ $votes = getAllVotes($id); /* line 27 */ $effectiveVote = $votes[0] - $votes[1]; return $effectiveVote; } $id = $_POST['id']; $action = $_POST['action']; //get the current votes $cur_votes = getAllVotes($id); //ok, now update the votes if($action=='vote_up') //voting up { /*line 41 */ $votes_up = $cur_votes[0]+1; $q = "UPDATE threads SET votes_up = $votes_up WHERE id = $id"; } elseif($action=='vote_down') //voting down { $votes_down = $cur_votes[1]+1; $q = "UPDATE threads SET votes_down = $votes_down WHERE id = $id"; } $r = mysql_query($q); if($r) //voting done { $effectiveVote = getEffectiveVotes($id); echo $effectiveVote." votes"; } elseif(!$r) //voting failed { echo "Failed!"; } ?>
-
PHP Notice: Undefined inde ERROR
Thats fair enough! Thanks for your time! I did actually manage to do it myself. Was actually really easy :L Is it possible to style a php echo. eg a border, background, font etc
-
PHP Notice: Undefined inde ERROR
Oh okay! note taken! Another quick question. At the moment the messages/post are being displayed as just the topic name and to see the message you click the topic and this takes you to a diffent page with the message. How do i get it so the whole message/post is displayed where the topic name is? This is the code for showing the topic name <?php // We are selecting everything from the threads section in the database and ordering them newest to oldest. $sql = mysql_query("SELECT * FROM threads ORDER BY posted DESC"); // Now we are getting our results and making them an array while($r = mysql_fetch_array($sql)) { // Everything within the two curly brackets can read from the database using $r[] // We need to convert the UNIX Timestamp entered into the database for when a thread... // ... is posted into a readable date, using date(). $posted = date("jS M Y h:i",$r['posted']); // Now we will show the available threads echo "<h3><a href='msg.php?id=$r['id']'>$r[title]</a> ($r[replies])</h3><h4>Posted by $r[author] on $posted</h4>"; // End of Array } ?> and the code that is for when clicking on the the topic name is the code you gave me
-
PHP Notice: Undefined inde ERROR
It works thanks! Can i ask... what did you change?
-
PHP Notice: Undefined inde ERROR
yes its exactly like this...
-
PHP Notice: Undefined inde ERROR
I have done this but its still displaying && It says posted when its not. Ive checked on the webpage and in the database :/
-
Like/Dislike button on posts
Right i kind of understand. so for the post_id i should use $_GET to get the id from the database for the message/post? Ive never used jquery yet i believe so i will read into it! Do you know any good tutorials i could follow? Ive googled so much but i just keep getting stupid facebook things
-
PHP display session username
This is what i use for my home page after logging it. Its displays a message and then the users username and if not logged in tells them to log in php if (isset($_SESSION['myusername'])) { echo 'LAD: '.$_SESSION['myusername']; } else { echo 'Please Login LAD!'; } ?></font>php if (isset($_SESSION['myusername'])) { echo '<a href="logout.php">Logout</a>'; } ?> Also you need to make sure <?php session_start(); if (isset($_SESSION['myusername'])) { session_destroy(); } ?> Is at the very top. I hope this is similar to what you need. Im very new to php to so im not sure how to adapt it to your code. This is just code ive found on net and changed for my own use
-
Like/Dislike button on posts
Hey Ive got a post/message board system in place. I would to add a "Like" and "dislike" function to each post. How can this be done? Is it .PHP , HTML or JAVASCRIPT Please aid me on how this can be done
-
PHP Notice: Undefined inde ERROR
Also when commeting of a post i first get Reply Posted. C:\xampp\htdocs\mywebsite\msg.php on line 41 12'>Return And when i click the link it displays Go Back...You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' Notice: Use of undefined constant id - assumed' at line 1 Can you help i dont understand what it is... <?php // Connecting to the database again mysql_connect("localhost", "root", ""); mysql_select_db("test"); // Here's a link that will allow you to go back to the index echo "<a href='Untitled9.php'>Go Back...</a>"; // This query selects the current thread using the $_GET value. $sql = mysql_query("SELECT * FROM threads WHERE id = " . $_GET['id'] . "") or die(mysql_error()); //Now we are getting our results and making them an array while($r = mysql_fetch_array($sql)) { // Here is the thread title. echo "<h2>$r[title]</h2>"; // Everything within the two curly brackets can read from the database using $r[] // We need to convert the UNIX Timestamp entered into the database for when a thread... // ... is posted into a readable date, using date(). $posted = date("jS M Y h:i",$r['posted']); // Now this shows the thread with a horizontal rule after it. echo "$r[message]<h4>Posted by $r[author] on $posted</h4><hr>"; // End of Array } echo "<h3>Replies...</h3>"; // Here we will get it to show the replies // This query selects the replies from the database where the thread ID matches the thread $_GET value. $sql = mysql_query("SELECT * FROM replies WHERE thread = '$_GET[id]'"); // Now we are getting our results and making them an array while($r = mysql_fetch_array($sql)) { // Everything within the two curly brackets can read from the database using $r[] // We need to convert the UNIX Timestamp entered into the database for when a thread... // ... is posted into a readable date, using date(). $posted = date("jS M Y h:i",$r[posted]); // Now this shows the thread with a horizontal rule after it. echo "$r[message]<h4>Posted by $r[author] on $posted</h4><hr>"; // End of Array } ?> <form action="newreply.php" method="POST"> Your Name: <input type="text" name="author"> /* Line 41*/<input type="hidden" value="<?php echo $_GET[id]; ?>" name="thread"><br> Message:<br><textarea cols="60" rows="5" name="message"></textarea><br> <input type="submit" value="Post Reply"> </form>