Results 1 to 3 of 3

Thread: Connect to database over a network

  1. #1
    Join Date
    Oct 2008
    Posts
    60
    Thanks
    2
    Thanked 7 Times in 7 Posts

    Default Connect to database over a network

    ive been trying to figure out how to connect to a mysql database over a network. basically i have a page on one network using sharepoint and i have the database on my computer. i use xampp for my server on my computer. when i display the document on sharepoint (Network A) i dont get an error saying that it connot connect, but just get the text "$row['']" displayed on the page. i added the comp ip = localhost in the host file in system32\drivers\etc file. here is my code:
    PHP Code:
    <?php
    $con 
    mysql_connect("localhost","root","");
    if (!
    $con)
       {
       die(
    'Could not connect: ' mysql_error());
       }
    mysql_select_db("db name"$con);
    $result mysql_query("SELECT * FROM tablename");
    while(
    $row mysql_fetch_array($result))
    {
    echo 
    "<table border='0' width='100%'>";
    echo 
    "<tr>"
    echo "<td width=3% align='left'><img src=\"" $row['image']. "\"></td>";
    echo 
    "</tr>";
    echo 
    "</table>";
    }
    mysql_close($con);
    ?>
    For the connect, ive tried connect("comp ip:3306","root",""); or 127.0.0.1:3306 or comp ip:3306@localhost. either way i dont get an error, just the ($row['image']) gets displayed in text, but nothing from the database.

    what can be going wrong? oh yeah, sharepoint does use php

  2. #2
    Join Date
    May 2007
    Location
    England, UK
    Posts
    235
    Thanks
    3
    Thanked 6 Times in 6 Posts

    Default

    SharePoint is a Microsoft product and uses ASP.NET not PHP.

    Therefore won't process the above code. Thats why you are seeing the raw PHP code in the browser.

  3. #3
    Join Date
    Oct 2008
    Posts
    60
    Thanks
    2
    Thanked 7 Times in 7 Posts

    Default

    well i can view php pages, and when i insert a database code the only thing that gets displayed is "$row['']" everything else gets treated as regular coding.

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
  •