I'm just learning this stuff and am having the trouble that something I wrote works on one computer, but not the other.
What I did was create a simple mysql database and table and a php page that calls first a menu of links for the entries in the table and then displays the entries if the link is clicked (I'm certain the code is easy to follow than what I just wrote.)
Anyway, it was first written on a mac OSX computer and ftp'd to a remote apache server running mysql where it works. I then tried to move it onto my windowsXP laptop, which runs mysql, php, and apache, but it didn't work there. I'd like to run it on my laptop because then I can build my site at home and without having to constantly ftp to test everything.
Here's the code...
<?php
//database connection details
$sql_host="localhost";
$sql_username="idw_web";
$sql_password="idworks";
$sql_db="idw_web";
//the sql connection.
$connection = mysql_connect($sql_host,$sql_username,$sql_password);
mysql_select_db($sql_db,$connection);
function menu() {
$result = mysql_query("select * from mycontent");
while ($newArray = mysql_fetch_array($result)){
$output = "<a href=\"$php_self?title=$newArray[contentID]\">".stripslashes($newArray[menutitle])."</a><br>";
echo $output;
}
}
function mycontent($id) {
$result = mysql_query("select * from mycontent where contentID = '$id'");
while ($newArray = mysql_fetch_array($result)) {
$output = "<h3>$newArray[contenttitle]</h3>";
$output .="<br>".stripslashes($newArray[content])."<br>";
$output .="my site 2001 etc";
}
return $output;
}
?>
<html>
<head>
<title>my first data driven php site</title>
</head>
<body bgcolor=white>
<table>
<tr>
<td valign=top align=left>
<?php
if ($title > 0) {
echo mycontent($title);
} else {
echo menu();
}
?>
</td>
<td>
</td>
</tr>
</table>
</body>
</html>
Can anyone help?