Log in

View Full Version : Connect to database over a network



fobos
12-22-2008, 01:45 PM
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
$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

jc_gmk
12-23-2008, 08:50 AM
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.

fobos
12-23-2008, 04:27 PM
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.