Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2011
    Posts
    67
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Inserting array values into database

    This is what I have so far, does not work.

    Code:
    foreach ($this->ipn_data as $key=>$value) {
            $query    = "INSERT INTO paybox ('$key') 
                 VALUES('$value')";
    			mysql_query($query,$link);
    		 
          }
    the $link is the
    Code:
    $link = mysql_connect($db_host,$db_user,$db_pass) or die('Unable to establish a DB connection');

  2. #2
    New Coder
    Join Date
    Nov 2011
    Posts
    67
    Thanks
    1
    Thanked 0 Times in 0 Posts

    So still not working

    I ended up echoing out my query

    Code:
    INSERT INTO paybox ('verify_sign') 
                 VALUES('AFsBMSMvEgrDc.j8KanEyiKNsJ8HAHog4f1AXfsZn-aaSPQAMO5xjKDU')
    I assumed that the single ticks were messing it up on the first value so I ran a str_replace, which did not remove them

    Code:
    $stunner =  str_replace( "'", " ",$key);
    So current code is

    Code:
       foreach ($this->ipn_data as $key=>$value) {
             if ($key == 'verify_sign'){
    		  $text .=  'this is the verify_sign' . $value . "\n";
    		  $stunner =  str_replace( "'", " ",$key);
    		   $query = "INSERT INTO paybox (".$stunner.") 
                 VALUES('".$value."')";
    			 $text .= 'this is query' . $query . "\n";
    			mysql_query($query,$link);
    			
    		  }
    	
    		 }

  3. #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,814
    Thanks
    78
    Thanked 575 Times in 562 Posts
    Quote Originally Posted by dawg View Post
    This is what I have so far, does not work.

    Code:
    foreach ($this->ipn_data as $key=>$value) {
            $query    = "INSERT INTO paybox ('$key') 
                 VALUES('$value')";
    			mysql_query($query,$link);
    		 
          }
    the $link is the
    Code:
    $link = mysql_connect($db_host,$db_user,$db_pass) or die('Unable to establish a DB connection');
    We don't use quote marks ' for the column names, we use back ticks ` which are normally on the key above the tab button to the left of the 1 button.
    Quote Originally Posted by deathshadow View Post
    So seriously, loosen up that tie, let out the belt, and try relating to normal people on the street instead of the gentleman's club crowd.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •