Results 1 to 2 of 2

Thread: PHP MySQL Data retreival... Problem?

  1. #1
    aka .:iGi:. Calcutter DannyM's Avatar
    Join Date
    Feb 2007
    Location
    Location Location!
    Posts
    915
    Thanks
    111
    Thanked
    125 times in 97 posts
    • DannyM's system
      • Motherboard:
      • Gigabyte Z68MA-D2H-B3
      • CPU:
      • Intel Core i5-2400
      • Memory:
      • 8GB Corsair Vengeance DDR3 - PC-12800
      • Storage:
      • 120GB A-Data SSD
      • Graphics card(s):
      • 1GB Nvidia ASUS 560Ti DirectuII
      • PSU:
      • Corsair 620W HX Modular PSU
      • Case:
      • Fractal Design Define Mini
      • Operating System:
      • Windows 7 Pro 64bit
      • Monitor(s):
      • 23" Dell UltraSharp U2311H
      • Internet:
      • 50Mb Virgin Media Cable Broadband

    PHP MySQL Data retreival... Problem?

    Hey folks,

    I'm still quite the newbie to PHP/MySQL, but I have done a website for Uni which worked perfectly well. I am trying to get some information using the following (just for testing right now).

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>testing</title>
    </head>

    <body>
    <?php
          
    // open connection  
            
    $connection mysql_connect("IPADDRESS""xxxxx""xxxxx") or die ("Unable to connect!");    
          
    // select database  
            
    mysql_select_db("xxxxx") or die ("Unable to select database!");     

        
    // Collects data from "ibf_topic" table 
            
    $data mysql_query("SELECT * FROM ibf_topics"
            or die(
    mysql_error());

        
    // puts the "ibf_topic" info into the $info array 
            
    $info mysql_fetch_array$data );

        
    // Print out the contents of the entry 
            
    Print "<b>TOPIC ID:</b> ".$info['topic_id'] . " "
            Print 
    "<b>TITLE:</b> ".$info['title'] . " <br>";

    ?> 
    </body>
    </html>
    Is there any reason why that should not work?

    Thanks

  2. #2
    Member
    Join Date
    Aug 2009
    Posts
    182
    Thanks
    3
    Thanked
    23 times in 22 posts
    • barry2811's system
      • Motherboard:
      • Gigabyte GA-Z87-HD3
      • CPU:
      • Intel i5 4670K (cooled by Noctua NH-D14)
      • Memory:
      • 2 x 8GB Corsair
      • Storage:
      • Samsung Pro 128GB Boot Drive, 1 x 6TB Seagate, 1 x 3TB Seagate and 256GB Crucial SSD for games
      • Graphics card(s):
      • Asus GTX970 Strix
      • PSU:
      • EVGA SuperNova 650 G2
      • Case:
      • NZXT S340 Elite
      • Operating System:
      • Windows 10
      • Monitor(s):
      • Viewsonic VG2439M-LED
      • Internet:
      • Sky Fibre

    Re: PHP MySQL Data retreival... Problem?

    You aren't specifying which row/record you want in the array. Try;

    Code:
    Print "<b>TOPIC ID:</b> ".$info['topic_id'][0] . " "; 
    Print "<b>TITLE:</b> ".$info['title'][0] . " <br>";
    for the first row/record. You might want to reverse the order of row number and fieldname - can't remember OTOH which way round they go. I usually use echo instead of print.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problem with my Kingston Data Traveller 1GB USN Stick
    By silentphoenix in forum SCAN.care@HEXUS
    Replies: 2
    Last Post: 29-10-2005, 11:28 AM
  2. Having problems writing to mySQL using PHP
    By Ramedge in forum Software
    Replies: 2
    Last Post: 12-10-2005, 11:42 PM
  3. Data Problem
    By xavxen in forum Help! Quick Relief From Tech Headaches
    Replies: 13
    Last Post: 08-09-2005, 03:12 PM
  4. Replies: 7
    Last Post: 17-06-2005, 01:54 PM
  5. Replies: 8
    Last Post: 21-05-2004, 09:58 PM

Posting Permissions

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