Jump to content

abrahamgarcia27

Members
  • Posts

    131
  • Joined

  • Last visited

Posts posted by abrahamgarcia27

  1. I did this. Do you think this can cause me a problem? Now i see that once their is a new tags for a new row it does not separate it with a comma :( i guess i have to do a tags table. Or do you see any way i can fix this. 

    function getBlogTags2(){
    
    	$db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); 
    	$sql = "SELECT tags FROM `".TABLE_BLOG."` ORDER BY RAND()"; 
    	$rows = $db->fetch_array($sql); 
    	
    	$data = array();
    	
    	foreach ($rows as $t) {
    		$theTags .= $t['tags'];
    	}
    	$theTags = explode(',', $theTags);
    
    	foreach ($theTags as $value) {
    		$data[] = $value;
    		
    	}
    	return $data;
    
    }
    

    Then to display i did this

    $tags = getBlogTags2();
    
    $random_keys=array_rand($tags,5);
    foreach ($random_keys as $key => $value) {
    	echo $tags[$value];
    	echo "<br>";
    }
    
  2. Yeah i was afraid that i needed to separate the tags table. Well i was thinking that i could do the following

     

    *bold are the ones that the random query would retrieve

     

    Blog Post 1 | john,carlos,micheal

    Blog Post 2 | test, test2, test3

    Blog Post 3 | php, testing, blog post

     

    Result Tags carlos, test3, php

    I know separating would make this taks really easy

  3. So i have a blog that has the tags store in one field in my blog table. So tags are saved as this in each blog post with its respective tags. 

     

    Tags: john, carlos, the great tag, this is a tag

     

    What i want to do is get random tags from each blog post and display them. I am not sure how i can begin to make this query. Do you guys have an idea on how to do this? 

     

     

  4. I have a click handler that is causing some problem. I am using hammer.js for a slider. 

     

    This is the link http://ingrub.com/iphone/

     

    When you hit the last slide the text of next changes to let's grub, but the problem is that if you swipe back to an earlier screen and you try to go next it automatically goes to the link instead of going to the next slide these are some of the functions that i am using 

    this.showPane = function(index, animate) {
                // between the bounds
                index = Math.max(0, Math.min(index, pane_count-1));
                current_pane = index;
    
                var offset = -((100/pane_count)*current_pane);
                setContainerOffset(offset, animate);
                
                
    
                if(current_pane == 2){
                    $(".next2").text("Let's Grub");
                    $(".navigation2").addClass('linkMe');
    
                    
                } else {
                    $(".next2").text("Next");
                    $(".navigation2").removeClass('linkMe');
                }
    
        
            };
    $( ".next2" ).click(function() {
            carousel.next();
    
           $('.linkMe').click(function() {
                window.location = "discover.html";
            });
           return false;
        });
    

    I am not sure what to do to fix this bug. 

  5. When i was developing the API i had problems with the apache_request_headers so i added the following function to fix the issue 

    if( !function_exists('apache_request_headers') ) {
        function apache_request_headers() {
            $arh = array();
            $rx_http = '/\AHTTP_/';
    
            foreach($_SERVER as $key => $val) {
                if( preg_match($rx_http, $key) ) {
                    $arh_key = preg_replace($rx_http, '', $key);
                    $rx_matches = array();
               // do some nasty string manipulations to restore the original letter case
               // this should work in most cases
                    $rx_matches = explode('_', $arh_key);
    
                    if( count($rx_matches) > 0 and strlen($arh_key) > 2 ) {
                        foreach($rx_matches as $ak_key => $ak_val) {
                            $rx_matches[$ak_key] = ucfirst($ak_val);
                        }
    
                        $arh_key = implode('-', $rx_matches);
                    }
    
                    $arh[$arh_key] = $val;
                }
            }
    
            return( $arh );
        }
    }
    

    I believe this is the problem. i am going to try to change environment see if i get a different result 

  6. I am not getting any error log 

    this are the latest one

     

    /home/ingrub/public_html/api/v2/index.php on line 53
    [05-May-2014 04:31:16 UTC] PHP Fatal error:  Call to a member function get() on a non-object in /home/ingrub/public_html/api/v2/index.php on line 53
    [05-May-2014 04:32:13 UTC] PHP Fatal error:  Call to a member function post() on a non-object in /home/ingrub/public_html/api/v2/index.php on line 53
    [05-May-2014 05:39:50 UTC] PHP Parse error:  syntax error, unexpected T_VARIABLE in /home/ingrub/public_html/api/v2/index.php on line 67
     
    its weird because when i use it in my rest application to call the info it works fine, but not via ajax so i have a feeling something is wrong with the jquery function this is the console log error from the browser
     
    Failed to load resource: the server responded with a status of 404 (Not Found) http://api.ingrub.com/v2/locations/32.6724822/-116.9447485
    XMLHttpRequest cannot load http://api.ingrub.com/v2/locations/32.6724822/-116.9447485. Invalid HTTP status code 404 index.html:1
  7. I am having an error doing an ajax call to this REST point this is the point http://api.ingrub.com/v2/locations/32.6724822/-116.9447485

     

    this is the ajax function with jquery

     $.ajax({
            url: 'http://api.ingrub.com/v2/locations/32.6724822/-116.9447485',
            type:  "GET",
            beforeSend: function(xhr){xhr.setRequestHeader('auth', 'b26d5f5881f8a030e2d33085a65ad15e');},
            dataType: 'json',
            success: function(response) {
          
            }
          });
    

    I get a 404 error Not Found. Any ideas why this might be happening? 

  8. I have an ubuntu server that i use locally and it does not add slashes when i insert data to the database, but when i put it on my dedicated server with centos it does add slashes and it is the same code. Do you guys have an idea of what it could be?

  9. I have this query that is not working and i have a feeling it has to do with the equation. Could some one take a look and see where i could be going wrong

    $sql = "SELECT name, category_id, image, ( 3959 * acos( cos( radians(37) ) * cos( radians( $latitude ) ) * cos( radians( $longitude ) - radians(-122) ) + sin( radians(37) ) * sin( radians( $latitude ) ) ) ) AS distance FROM `".TABLE_RESTAURANTS."` HAVING distance < 25 ORDER BY distance LIMIT 0 , 20"; 
    
  10. Ok this is what i am using for .htaccess

    RewriteRule    ^post/([A-Za-z0-9-]+)/?$      index.php?action=blogpost&title=$1    [NC,L]
    

    This is how i send the title to query 

     $urlTitle = strtolower(str_replace(' ', '-', $blogs['title']));
    
    <div class="post-meta-readmore"><a href="<?php echo SITE_PATH; ?>post/<?php echo $urlTitle; ?>">Read more</a> </div>
    

    And this is how i query the post

    function getBlog($title){
    	
    	$string = str_replace('-', ' ', $title);
    	$db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
    	$sql = "SELECT * FROM `".TABLE_BLOG."` LEFT JOIN `".TABLE_BLOG_CAT."` ON `".TABLE_BLOG."`.category_id = `".TABLE_BLOG_CAT."`.category_id WHERE title = '$string' LIMIT 1";
    	$record = $db->query_first($sql);
    	return $record;
    }
    
  11. I have a question on how to structure my url for a blog. Before i used the ID of the blog_id, but i feel i should add the title of the post (Like they do on this forum). Then i added the the title to the blog to query the blog post, but i came across the problem that the title was similar. I am just trying to get some knowledge from my fellow friend on how to structure a url path for SEO. I use .htaccess for rewriting my urls this is the structure i use.

     

    Also some people added characters which broke my query like (;,"'@^, etc...)

     

    index.php?action=blogpost&title=$title /blog/post/$blog_title

    index.php?action=blogpost&blog_id=$blog_id /blog/post/$blog_id

  12. I have been trying to save variable into an array, but i cannot seem to make it work i have the following and it does not print the results. 

    $myData = array();
    						
    		foreach ($_POST as $values) {
    			$myData[] = array(
    				'rep'            => $values['rep'],
    				'declared'           => $values['declared'],
    				'detail_id' => $values['detail_id']
    			);
    		}
    
    		print_r($myData);
    
×
×
  • 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.