SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    Git-R-Done
    Join Date
    Nov 2001
    Posts
    1,194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Variables/Values and MySQL

    I'm using a script that retrieves info from a URL and creates the values like: $value[$i]["name"] then I echo them in the page like: ".$value[$i]["name"]."

    How can I take this and put it into a MySQL database then retrieve it within the same script? So for example, I have a few values I need to pull from one page and a bunch more that are from a MySQL database. I would like it so when I access the page it gets the values from the URL, updates them in the database, then retreives the info to print on the page. Can somebody tell me what is wrong with my script? I can't get it to insert the data to the table in the database.

    Here is a part of the code I'm using that I'm having problems with:

    PHP Code:
    <?
    /* connect to mysql database */
    include "/home/login/content/dba.php";
    mysql_connect(localhost,$username,$password);
    @
    mysql_select_db($database) or die( "Unable to select database");

    stuff....

    $value[$i]["name"]

    $sql "INSERT INTO contacts SET
    name = 'name',
    etc.
    etc.
    WHERE ID= '
    $id'";
    ?>

    <table width="520" border="0" cellpadding="3" cellspacing="0">
      <tr>
        <td>Name<td>
      </tr>
      <? 
      $query 
    "SELECT * FROM contacts";
      
    $result mysql_query($query) or die ("Query Failed");
      
    $numofrows mysql_num_rows($result);
      for(
    $i=0$i<sizeof($value); $i++){
      if (
    $i 2) {  
          echo 
    "<tr bgcolor=\"F1F1F1\"\n";  
      } else {  
          echo 
    "<tr bgcolor=\"FFFFFF\"\n";  
      }  
      echo 
    "<td>".$value[$i]["name"]."</td>\n";
      }
      
    ?>
      </tr>
    </table>
    Any help would be greatly appreciated.
    John Saunders

  2. #2
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks like you need another query for $sql... that statement is never getting presented to mySQL.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?


Bookmarks

Posting Permissions

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