Jump to content

Spring

Members
  • Posts

    224
  • Joined

  • Last visited

Posts posted by Spring

  1. THESE ARE BEING LOADED GOD DAMMIT

    $autoload['libraries'] = array('database', 'image_lib');

     

    I seriously can't do this without loading the database directly! I get: Call to a member function get() on a non-object WHEN I DONT LOAD THE DB DIRECTLY

     

    class Port_model extends CI_Controller {
    
    function __construct() {
    	parent::__construct();
    }
    
    function getData()
    {
    	$query = $this->db->get('port');
    
    	if ($query->num_rows() > 0) {
    		//Lets get our data from announcements and pass it to an array
    		foreach ($query->result() as $row) {
    			$data[] = $row;
    		}
    	} return $data;
    }
    
    }

     

    and i think its the damn .htaccess!!!

    ALSO, I CANT LOAD THE IMAGE LIB LIBRARY WITHOUT GETTING A SIMILAR FUCKING PROBLEM. IS THIS THANKS TO .HTACESS!?

     

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /ci/
    
        #Removes access to the system folder by users.
        #Additionally this will allow you to create a System.php controller,
        #previously this would not have been possible.
        #'system' can be replaced if you have renamed your system folder.
        RewriteCond %{REQUEST_URI} ^system.*
        RewriteRule ^(.*)$ /ci/index.php?/$1 [L]
        
        #When your application folder isn't in the system folder
        #This snippet prevents user access to the application folder
        #Submitted by: Fabdrol
        #Rename 'application' to your applications folder name.
        RewriteCond %{REQUEST_URI} ^application.*
        RewriteRule ^(.*)$ /ci/index.php?/$1 [L]
    
        #Checks to see if the user is attempting to access a valid file,
        #such as an image or css document, if this isn't true it sends the
        #request to index.php
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /ci/index.php?/$1 [L]
    </IfModule>
    
    <IfModule !mod_rewrite.c>
        # If we don't have mod_rewrite installed, all 404's
        # can be sent to index.php, and everything works as normal.
        # Submitted by: ElliotHaughin
    
        ErrorDocument 404 /index.php
    </IfModule>  

     

  2. <?php
            $db = new Database();
    
    $q = "SELECT 
    	post_id,
    	post_title,
    	post_subtitle, 
    	post_body, DATE_FORMAT(post_created, '%M %D %Y') AS created_on,
    	post_ext_link
    	FROM blog 
    	ORDER BY post_id DESC
    	LIMIT 3";
      
            $r = $db->query($q); 
          if (mysqli_num_rows($r) > 0) {	 
    		  while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
    		  echo
    		  "<h2>" . $row['post_title'] . "</h2>" .
    		  "<h3" . $row['post_subtitle'] . "</h3>" . 
    		  "<p" . $row['post_body'] . "</p>" .
    		  "<p" . $row['created_on'] . "</p>"
    		  ;
        	}
    	  } else {
    	  	echo '<p>No posts to display at present.</p>';
    	  }
    ?>

  3. $sql = "SELECT poster_id from phpbb_posts WHERE topic_id = ".$topic_id." ";
    $result = $db->sql_query($sql); //same as mysql_query
    $row = $db->sql_fetchrow($result); // same as mysql_fetch array.
    var_dump($row);
    

     

    With this code (i commented the query function for you) im getting

    array
      'poster_id' => string '59' (length=2)

     

    When I run this into SQL in phpmyadmin I'm getting

    59 56 //this is what I want
    

     

    I need to get all of the records, not just the first one. I have even tried using replacing the function with mysql_query and mysql_fetch_array

    any ideas? It's a bit late, so I may just be making a simple mistake.  Thanks!

  4. There sure is! Here it is:

     

    function totallyAwesomeFunctionForTonyhhInsertQueries($tableName, $values, $keys = array()) {
       $insert = "INSERT INTO `{$tableName}`";
    
       if (count($keys) > 0) {
          $insert .= "`". implode("`,`", $keys) ."`";
       }
    
       $insert .= " VALUES";
    
       foreach ($values as $key => $value) {
          $insert. = "'". implode("', '", $value) ."'";
       }
    
       return $insert;
    }
    

     

    And if you want to insert the same value again and again, there is another function for that!

     

    function totallyAwesomeFunctionForTonyhhInsertQueryRepeat($query, $times) {
       for ($i = 0; $i < $times; $i++) {
          mysql_query($query);
       }
    }
    

     

    I tickle myself sometimes... Anyways, point is, you can make functions...

     

    Well yeah, I just didn't know how to approach it, but thanks!

     

    (Keeping the function name)

  5. Is there a function which will allow me to throw the values into an array and post them into the DB as separate records? If so a little help would be appreciated!

    if(empty($row))
    	{
    		//Need a better way.
    		$sql = "INSERT INTO phpbb_user_items
    		VALUES
    		(13, '$user_id', '0'),
    		(12, '$user_id', '0'),
    		(11, '$user_id', '0'),
    		(9, '$user_id', '0'),
    		(27, '$user_id', '0'),
    		(15, '$user_id', '0'),
    		(16, '$user_id', '0'),
    		(22, '$user_id', '0'),
    		(21, '$user_id', '0'),
    		(23, '$user_id', '0'),
    		(24, '$user_id', '0'),
    		(26, '$user_id', '0'),
    		(29, '$user_id', '0'),
    		(30, '$user_id', '0'),
    		(31, '$user_id', '0'),
    		(32, '$user_id', '0'),
    		(33, '$user_id', '0')
    		";
    		$result = $db->sql_query($sql);
    	}

  6. function buildAvatar(array $imgArray = array())

    {

    $img1 = imagecreatefrompng($phpbb_root_path.'images/spacer.png');

    foreach($imgArray as $img)

    {

    $img2 = imagecreatefrompng($phpbb_root_path.'avatars/equip_img/'.$img);

    $this->imagecopymerge_alpha($img1, $img2, 0, 0, 0, 0, 210, 300, 100);

    }

    imagealphablending($img1, false);

    imagesavealpha($img1, true);

    return $img1;

    }

     

    The background of my PNG was transparent, I don't know what I did, but it's now black! I'm thinking it's the image! Not the code, this same code worked before, and I've tried tons of different ways of fixing it. How should I save the image to work correctly?

  7. I'm trying to alow users to reference links, but I'm stumped.

     

    $com = preg_replace("/(^|<<)(<<[^<]*[0-9])/", "\\1<a href = #".$com.">#$com</a>\\2</div>", $com);

     

    If I typed <<#123 I would get:

    #<<123<<123

     

    and it would link to <<123

     

    The output I'm looking for is

     

    <<#123

     

    and have it link to

    #123

  8. Script for web page:

     

    		<script type="text/javascript">
    
    		function Ajax()
    		{
    			var
    				$http,
    				$self = arguments.callee;
    
    			if (window.XMLHttpRequest) {
    				$http = new XMLHttpRequest();
    			} else if (window.ActiveXObject) {
    				try {
    					$http = new ActiveXObject('Msxml2.XMLHTTP');
    				} catch(e) {
    					$http = new ActiveXObject('Microsoft.XMLHTTP');
    				}
    			}
    
    			if ($http) {
    				$http.onreadystatechange = function()
    				{
    					if (/4|^complete$/.test($http.readyState)) {
    						document.getElementById('ReloadThis').innerHTML = $http.responseText;
    					        setTimeout(function(){$self();}, 6000)	
    					}
    				};
    				$http.open('GET', 'random.php' + '?' + new Date().getTime(), true);
    				$http.send(null);
    			}
    
    		}
    
    	</script>

     

    Also include this in the 'body' which is the additional loader before the above takes effect.

     

    		<script type="text/javascript"> //ADDITIONAL LOADER BEFORE ABOVE LOADER CURRENTLY AT 6000.
    		setTimeout(function() {Ajax();}, 1000);
    	</script>

     

    then add random.php and add the code you want it to load.

     

    Thanks! Really appreciate it.

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