Jump to content

HoTDaWg

Members
  • Posts

    275
  • Joined

  • Last visited

Posts posted by HoTDaWg

  1. hi there,

     

    i have gain theoretical knowledge from a PHP book, and i have also made my own Blog entirely from scratch! (IM SO PROUD:) lol) but now i want to gain more practical knowledge by looking at the code of others.  The problem is that a lot of the applications i look @ are way to complex for me to understand and wrap my head around.

     

    do you guys know of any smaller-scale PHP applications that are perhaps easier to follow?

     

    any help would greatly be appreciated,

    thanks,

     

    HoTDaWg

  2. I had that problem myself about a week ago.

    the nl2br function will make the structure from your post the same when you output it back onto the page.

     

    in addition,

    to prevent uses from being able to type aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa and exceeding the width of the textarea i used a custom function i came accross this site the other day, I use it myself and should work great for you too.

    <?php
    //taken from http://www.codingforums.com/archive/index.php/t-168890.html
    //just include this function at the top of the page or another file
    function wraptext($str, $limit)
    	{
    		$break = "<br>";
    		$limit = ( int ) $limit;
    		return ($limit > 0
    		? preg_replace('/(\S{' . ( $limit + 1 ) . ',})/e',
    						'wordwrap( \'\1\', ' . $limit . ', \'' . $break . '\', TRUE )',
    						$str )
    							: $str);
    }
    $string = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
    // and call upon it before you insert your post data into the database
    $finalcomment = wraptext($newcomment,50);
    
    //this function will seperate lengthy sets of characters
    
    ?>
    

     

    i hope this helps

    believe me it took me so long to find a solution for that problem

     

    HoTDaWg

  3. hi there,

     

    heres the code im using for my inner join

    <?php
    $query = "SELECT * FROM blog_history INNER JOIN blog_links"
    			. " USING(history_shared == link_id) WHERE blog_history.history_type='3'"
    			. " LIMIT $skip,$results_per_page ORDER BY blog_history.history_id DESC";
    ?>
    

     

    here is the structure for these two tables:

    blog_history

    CREATE TABLE IF NOT EXISTS `blog_history` (
      `history_id` int(50) NOT NULL AUTO_INCREMENT,
      `history_type` varchar(250) DEFAULT NULL,
      `history_date` varchar(250) DEFAULT NULL,
      `history_shared` varchar(250) DEFAULT NULL,
      PRIMARY KEY (`history_id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
    

     

    blog_links

    CREATE TABLE IF NOT EXISTS `blog_links` (
      `link_id` int(50) NOT NULL AUTO_INCREMENT,
      `link_type` varchar(50) DEFAULT NULL,
      `link_title` varchar(500) DEFAULT NULL,
      `link_link` varchar(7000) DEFAULT NULL,
      `link_description` varchar(1500) DEFAULT NULL,
      `link_date` varchar(100) DEFAULT NULL,
      PRIMARY KEY (`link_id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
    

     

    any ideas where i went wrong in the query structure guys?

     

    any help would be greatly appreciated, thanks,

     

    HoTDaWg

  4. okay so

    $_POST is an ARRAY

    by naming each of your textboxes as td_venue[] you are creating an ARRAY within the $_POST array

    if that makes sense, i know it can be confusing.

     

    so by referring to $_POST['td_venue'] you are referring to all of the returned checkboxes from the form. so by using the foreach loop you can do certain things to all of the CHECKED checkboxes of the user. Foreach allows you to distinguish what to do with each of the checkboxes.

     

    i hope this helps

     

    HoTDaWg

  5. im not quite sure what you're asking but i hope this helps

    <?php
    //to insert the data into the database.
    foreach ($_POST['td_venue'] => $key as $value){
       //escape the string here, however you see fit.
       $query = "INSERT INTO tablename VALUES ('$value') ";
       $result = mysql_query($query);
       if ($result) {
          echo $value . ' was added.';
      }
    }
    ?>
    

     

    change this accordingly i hope it gives you an idea as to what the code should look like.

  6. change:

    <?php
    while ($results = $mysql_fetch_assoc($query_db)) {
    ?>
    

     

    to:

    <?php
    while ($results = mysql_fetch_assoc($query_db)) {
    

     

    not sure if itll fix the problem, not even sure THAT is line 26, but thats gotta be an error.

    did you even look at line 26:S?

  7. hi there

     

    i get a feeling this is a really stupid question and i apologize for not trying harder to figure it out, i just cant get my head around it and my deadline is slowly winding down.

     

    im trying to replace a string such as "8 2009" (or "12 2009") to just "8" here is what i have been experimenting with, but i cant seem to get it right:

    <?php
    $thatmonth = "8 2009";
    preg_replace('/^[\d]+[\s\d]+$/','/^[\d]+$/',$thatmonth)
    ?>
    

     

    any help would be greatly appreciated, thanks

     

    HoTDaWg

  8. <?php
    $connection = mysqli_connect('localhost','username','password','db_name')
    $query = "SELECT * FROM video_cat_tbl";
    $result = mysqli_query($connection,$query);
    while($row = mysqli_fetch_array($result){
    {
       echo $row['video_cat'] . '<br>';
       $query2 = "SELECT * FROM video_tbl WHERE video_cat_id ='".$row['video_cat_id']."' LIMIT 2";
       $result2 = mysqli_query($connection, $query2);
       while($row2 = mysqli_fetch_array($result2)){
          echo $row2['video_title'] . '<br>';
       }
    }
    ?>
    

    Based on your description, here is my interpretation.

    HoTDaWg

     

     

  9. nl2br does not work for me because assuming the user was to hold down the "a" key, a series of A's would appear and there would be no line breaks at all, this series of A's would need seperation as it could potentially ruin my layout. Thats why i have been using wordwrap, because it wraps long series of texts anyways, whether they have a /n or not

     

    right now im thinking to create a custom function, that based on if the string has spaces it would put in a <br>

     

    any other ideas?

  10. hey guys,

     

    so in my textarea im using wrap="virtual" and it gets the job done.  The problem is that if a user were to type in a long string of A's or paste a link for example, this ruins my design when it shows up. 

     

    Currently I am utilizing the word wrap function to place a <br> every 50 characters (which is how much, approximately width-wise, my textarea can hold per line); the problem is that assuming a user were to type his comment spread out on multiple lines, it would create a <br> for no reason just because its the 50th character, this is effecting my emoticon system.

     

    here is a copy of the code:

    <?php
    $codes = array(''=>'<img src="includes/images/emoticon_tongue.png">',
    	''=>'<img src="includes/images/emoticon_unhappy.png">',
    	 ''=>'<img src="includes/images/emoticon_wink.png">',
    	'XD'=>'<img src="includes/images/emoticon_evilgrin.png">',
    	''=>'<img src="includes/images/emoticon_happy.png">',
    	''=>'<img src="includes/images/emoticon_smile.png">',
    	''=>'<img src="includes/images/emoticon_surprised.png">');
    while($row = mysqli_fetch_array($result)){
    	$newnewcomment = $row['comment_comment'];
    	$dacomment = stripslashes($newnewcomment);
    	$newnewnewcomment = wordwrap($dacomment,'50','<br>',true);
    	$finalcomment = str_replace(array_keys($codes),array_values($codes),$newnewnewcomment);
    	$comments .= '<hr><b>'.$row['comment_name'].'</b> Wrote on '
    		. date('l, F jS, Y g:i A',$row['comment_date']).':<br><br>'
    		. $finalcomment . '<br>';
    
    }
    ?>
    

    even if i placed the line that substitutes emoticons in front of the line that wraps the word, the wordwrap would include the <img src> tags and consider them as characters, it would place breaks within the image tags...

     

    any ideas guys?:S

     

    thanks,

     

    HoTDawg

  11. okay so adding to my problem,

     

    my main issue is just with a comment section i am designing.

    the problem is whenever a user is to enter a comment (via a textarea) such as:

    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

    where the width of the letters exceeds the width of the page, it ruins my whole layout.

     

    ive tried setting the textarea to wordwrap=hard

    and ive tried the wordwrap function and my own custom function

     

    how do you guys deal with word wrapping the values of text areas so that they do not ruin your layout?

  12. bro,

     

    your form action is action.php yet your method is equal to post...

    if your gonna be using the $_POST method of retrieving data than your form's action should be $_SERVER['PHP_SELF'] otherwise if you are using the get method than the form should be set to: <form name="formname" action="action.php" method="get">

    if it is the get method ur gonna be using:

    the action.php should like

    <?php
    //action .php
    $mode = $_GET['mode'];
    echo $mode;
    ?>
    

     

    HoTDaWg

  13. hey guys,

     

    the wordwrap function was not working for me, so i decided to try to create my own function; the problem is i keep getting this error saying that im using an Uninitialized string offset: 128.  Could the problem be with how i wrote the code? or does the problem lye elsewhere?

    <?php
    while($row = mysqli_fetch_array($result)){
    	$thethecomment = $row['comment_comment'];
    	$newnewcomment = '';
    	for($d=0; $d<=strlen($thethecomment); $d++){
    		if ($d%10 == 0){
    			$newnewcomment .= '<br>' . $thethecomment{$d};
    		}else{
    			$newnewcomment .= $thethecomment{$d};
    		}
    	}
    	$comments.= '<hr><b>'.$row['comment_name'].'</b> Wrote on '
    		. date('l, F jS, Y h:i a',$row['comment_date']).':<br><br>'
    		. $newnewcomment . '<br>';
    }
    ?>
    

    basically it should be outputting the comment(taken from the database) and putting a <br> every 10 characters. but all it does is return this error.

     

    any ideas?

    thanks for any help possible.

     

    HoTDaWg

×
×
  • 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.