php and mysql help is needed.

Discussion in 'PHP' started by exodus, Aug 30, 2007.

  1. #1
    I am not exactly sure why this is not working. It checks to make sure certain fields are present and if they are not present it try's to create them. It is an update to one of my scripts, but I can not figure out why it is not working correctly. Any help would be great. Thanks!

    <?php
    
    $inscript = true;
    
    include('config.php');
    
    $result = mysql_query("SELECT `adsense_pubid`,`adsense_channel` FROM `".$SQL_Ext."_settings`");
    
    if(0 == $result)
    {
     $result = mysql_query('ALTER TABLE `'.$SQL_Ext.'_settings` 
                    ADD `adsense_pubid` VARCHAR( 100 ) NOT NULL AFTER `add_to_site` , 
                    ADD `adsense_channel` VARCHAR( 100 ) NOT NULL AFTER `adsense_pubid`');
     if(0 != $result)
     { 
       echo 'Updated your SQL with the adense varibles<br />';
       echo 'If you have not already add the following to your<br />';
       echo './includes/config.php at the bottom before the '.chr(63).'><br /> ';
       echo '$adsense_pubid = $row[\'adsense_pubid\'];<br />
             $adsense_channel = $row[\'adsense_channel\'];';
      }
      else 
      {
        echo 'Contact exodus something is wrong. The update can not create the needed sql fields.';
      }                                                           
    }
    else 
    {
       echo 'Your site has already been updated<br />';
       echo 'If you have not already add the following to your<br />';
       echo './includes/config.php at the bottom before the '.chr(63).'> ';
       echo '$adsense_pubid = $row[\'adsense_pubid\'];<br />
             $adsense_channel = $row[\'adsense_channel\'];'; 
    }
                          
    ?>
    PHP:
     
    exodus, Aug 30, 2007 IP
  2. ndreamer

    ndreamer Guest

    Messages:
    339
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    thats a mean and slow way to get the table names :confused:
    try something like
    DESCRIBE the_table_name;

    for your mysql query, this will return the column names as well as there types.
     
    ndreamer, Aug 30, 2007 IP