Jump to content

lostprophetpunk

Members
  • Posts

    270
  • Joined

  • Last visited

    Never

Everything posted by lostprophetpunk

  1. Isn't there anyone that can help? I mean this by converting the html code that was converted by using the function in the code above, and converting that into the bbcode that was originally converted.
  2. Try making the '<?=' a '<?php' instead, as the first I have never seen as a PHP opening tag, only '<?php' and '<?'.
  3. I am working on an edit script for my article system, however I have come across a problem. This code is for my posting script so that the bbcode is converted to html... function bbcode_format ($posted) { $posted = htmlentities($posted); $simple_search = array( '/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is', '/\[url\=(.*?)\](.*?)\[\/url\]/is', '/\[n]/is', '/\[img\=(.*?)\](.*?)\[\/img\]/is' ); $simple_replace = array( '<b>$1</b>', '<i>$1</i>', '<u>$1</u>', '<a href="$1" target="_blank">$2</a>', '<br />', '<img src="$1" alt="$2" />' ); // Do simple BBCode's $posted = preg_replace ($simple_search, $simple_replace, $posted); return $posted; }; I would like to make it so that the function converts the html into the bbcode so that it can be edited.
  4. The $Data['entry']; isn't showing all of it's data.
  5. I have been working on a way to edit articles in my blog system. I have come across a problem though. I get the article id that is set in the link, and then display the results in a form. I then set variables that contain the information in the database. I then echo the variables as values in the form. I can get the title to work but the thing is that the data in the database isn't all being put in the variable, as only part of it shows in the form... Below is the code for my edit page... <?php include("../connection.php"); include("../header.php"); if($session_name){ $editid = $_GET['id']; $editid = mysql_real_escape_string( $editid ); $Query = mysql_query(" SELECT * FROM articles WHERE article_id='$editid' "); $Data = mysql_fetch_array( $Query ); $title = $Data['article_name']; $entrye = $Data['entry']; echo "<div class='mainc'>\n"; echo "<div class='maintop'>Edit Article</div>\n"; echo "<div class='main'>\n"; echo "<form name=\"addpost\" method=\"post\" action=\"postd.php\">\n"; echo "Title <input type=\"text\" name=\"name\" value=\"$title\"><br />\n"; echo " <textarea rows=\"20\" cols=\"60\" name=\"entry\" wrap=\"virtual\" onkeyup=\"f=document.addpost;f.char_count.value=f.entry.value.length;\" value=\"$entrye\"></textarea>\n"; echo "<input type=\"readonly\" name=\"char_count\" size=\"2\" /><br />\n"; echo "<input type=\"submit\" name=\"submit\" value=\"Post\"><br />\n"; echo "</form>\n"; }else { echo "You have to be logged in to view this page.<br /><br />Redirecting you to the home page...\n"; echo "<meta http-equiv=\"refresh\" content=\"3;url=../\" />\n"; } echo "</div>\n"; echo "<div class='mainbottom'></div>\n"; echo "</div>\n"; include("../footer.php"); ?> I have been thinking on how to fix this but returned nothing.
  6. Can anyone help? The the field entry does exist. I have tried it just with that and it works fine, but when I try to shorten the string it doesn't show anything but the '...' at the end.
  7. It does exist, as if I were to echo that by itself, it would post the full article.
  8. It still just outputs the '...' and nothing else.
  9. Right, I have tried placing that in my code, but it doesn't seem to work... $entrym = "".$Data['entry'].""; strip_tags(substr($entrym, 40, 100)); echo "$entrym...\n"; It just seems to echo the '...'.
  10. Hello, I am working on a posting system. I have come across a problem. I am trying to make it so that the main page only displays a set certain amount of words from the article, then add a '...' to the end. I have set it up so the full article will display on a different page. Below is the current code for my main page... echo "<div class='mainc'>\n"; while($Data = mysql_fetch_array($res)){ echo "<div class='maintop'>".$Data['article_name']."</div>\n"; echo "<div class='main'>\n"; echo "".$Data['entry']."\n"; echo "</div>\n"; echo "<div class='mainbottom'>#".$Data['article_id']." - Posted By <a href='#'>Matt</a> on ".$Data['date']." - <a href=\"article.php?article_id=".$Data['article_id']."\">Read More</a>\n"; echo "</div>\n"; } echo "</div><br /><br />\n"; I am looking for a way to shorten the ".$Data['entry']." (without permanently cutting down the size of the data) to a set certain length, and then add '...' to the end. How would I go about doing this?
  11. I am making a simple posting system. I have the following code to deal with the bbcode... function bbcode_format ($posted) { $posted = htmlentities($posted); $simple_search = array( '/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is' ); $simple_replace = array( '<b>$1</b>', '<i>$1</i>', '<u>$1</u>' ); // Do simple BBCode's $posted = preg_replace ($simple_search, $simple_replace, $posted); return $_POST['entry']; } The data of '$posted' is then inserted into the database. But when I view the post on a different page, it hasn't worked. Am I doing something wrong?
  12. In my database, I have a table called 'articles'. In that table, I have the following fields... article_id (which is a primary key) article_name entry poster date time But when I try to use the following code to insert values into there, it gives me an error likt eht one shown below the code... $sql = "INSERT INTO `articles` (article_id, article_name, entry, poster, date, time) VALUES('$name' , '$posted', 'today', '4:00pm')"; $res = mysql_query($sql) or die(mysql_error()); The error was - 'Column count doesn't match value count at row 1' So what am I doing wrong?
  13. I am creating a comment system for my website. I have set up the following fields in my database... id name email comment I have the form set up. How would I display comments in order from the oldest first? I get the reast of it but I do not know how to display them in order using the id field.
  14. The page loads fine just the image doesn't show.
  15. <a href="#"><img class="purchase" src="images/nav_purchase.gif" alt="Purchase" /></a> .purchase a:link { width: 142px; height: 28px; margin-left: 285px; background-image: url(images/nav_purchase.gif); padding: 5px; /*Do whatever padding is necessary to align text */ position: absolute; border: 0px; } .purchase a:visited { width: 142px; height: 28px; margin-left: 285px; background-image: url(images/nav_purchase.gif); padding: 5px; /*Do whatever padding is necessary to align text */ position: absolute; border: 0px; } .purchase a:hover { width: 142px; height: 28px; margin-left: 285px; background-image: url(images/nav_purchase_roll.gif); padding: 5px; /*Do whatever padding is necessary to align text */ position: absolute; border: 0px; } .purchase a:active { width: 142px; height: 28px; margin-left: 285px; background-image: url(images/nav_purchase.gif); padding: 5px; /*Do whatever padding is necessary to align text */ position: absolute; border: 0px; } Just remember to adjust the height and width of the div depending on the padding.
  16. All you needed to do was put 'text-align: center' in the wrapper CSS code. It's a known IE hack and works wonders. But make sure that you have all the other text-align things set in all of the places inside the wrapper div, otherwise all of your text will be centered.
  17. I am trying to use captcha to make my registration form safer. The only thing that is going wrong is that the captcha image is not showing... My host has a GD2 library, so it should work...shouldn't it? This is the code in a seperate file... <?php session_start(); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); function _generateRandom($length=6) { $_rand_src = array( array(48,57) //digits , array(97,122) //lowercase chars // , array(65,90) //uppercase chars ); srand ((double) microtime() * 1000000); $random_string = ""; for($i=0;$i<$length;$i++){ $i1=rand(0,sizeof($_rand_src)-1); $random_string .= chr(rand($_rand_src[$i1][0],$_rand_src[$i1][1])); } return $random_string; } $im = @imagecreatefromjpeg("captcha.jpg"); $rand = _generateRandom(3); $_SESSION['captcha'] = $rand; ImageString($im, 5, 2, 2, $rand[0]." ".$rand[1]." ".$rand[2]." ", ImageColorAllocate ($im, 0, 0, 0)); $rand = _generateRandom(3); ImageString($im, 5, 2, 2, " ".$rand[0]." ".$rand[1]." ".$rand[2], ImageColorAllocate ($im, 255, 0, 0)); Header ('Content-type: image/jpeg'); imagejpeg($im,NULL,100); ImageDestroy($im); ?> This is my test page... <?php session_start() ?> <form method="post" action=""> <table bgcolor="#CCCCCC"> <tr><th>Contact us (Post new message):</th></tr> <tr><td><textarea cols="30" rows="5" name="message"></textarea></td></tr> <tr><td align="center">CAPTCHA:<br> (antispam code, 3 black symbols)<br> <table><tr><td><img src="captcha.php" alt="captcha image"></td> <td><input type="text" name="captcha" size="3" maxlength="3"></td></tr></table> </td></tr> <tr><th align="center"><input type="submit" value="Submit"></th></tr> </table> </form> <?php if(isset($_POST["captcha"])) if($_SESSION["captcha"]==$_POST["captcha"]) { //CAPTHCA is valid; proceed the message: save to database, send by e-mail ... echo 'CAPTHCA is valid; proceed the message'; } else { echo 'CAPTHCA is not valid; ignore submission'; } ?>
  18. I am making stuff for my site and I need to know if my login script is safe enough... <?php require_once('include.php'); $error = ''; $form = $_POST['submit']; $username = mysql_real_escape_string( $_POST['username'] ); $password = mysql_real_escape_string( $_POST['password'] ); //$MD5password = md5( $password ); if( isset($form) ) { if( isset($username) && isset($password) && $username !== '' && $password !== '' ) { $MD5password = md5( $password ); $MD52password = md5( $MD5password ); $sql = mysql_query("SELECT * FROM `usersystem` WHERE username='$username' and password='$MD52password';"); if( mysql_num_rows($sql) != 0 ) { //success $_SESSION['logged-in'] = true; header('Location: members.php'); exit; } else { $error = "Incorrect login info"; } } else { $error = 'All information is not filled out correctly';} } ?> <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Login</title> </head> <body> <form action="<?php $PHP_SELF; ?>" method="post" > Username: <input name="username" type="text" value="<?php echo "$username";?>" /><br /><br /> Password: <input name="password" type="password" /><br /> <input name="submit" type="submit" value="Log In" /> </form> <?php echo "<br /><span style=\"color:blue\">$error</span>"; ?> </body> </html> If it is not safe, could you give me pointers on how to make if more safe?
×
×
  • 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.