I've built with PHP before, but just basic stuff. This is my very first time using a database, and I'm hitting a brick wall. I'm a total n00b, of course. That's the trend for this board, right? 😉
I'm not sure what's going wrong here. I think I've included every semi-colon, quote, dollar sign, and parenthesis that I need. I've checked the basic logic, and I think it's sound. At least, it shouldn't be giving me the errors I'm seeing. Here is the code. I've pulled the code right out of the "include" files and dropped them in the code, so there's only one section to see. The output (errors) are also posted below, along with a link to the file.
Since I'm just building this site and seeing what's possible, no data entry checking is included yet. I (obviously) will be including this once the script actually runs correctly.
<?php
echo "<html><body>";
// for low-level access, username = lcgsteve_member password = member
$db = mysql_connect("localhost", "lcgsteve_member", "member");
$db_selected = mysql_select_db("lcgsteve_news", $db);
// I want to count the number of rows so I know how many news items to print
$query = "SELECT * FROM news";
$result = mysql_query($query, $db);
$row = mysql_num_rows($result);
// Each news item displays, with the most recent at the top.
for ($i = 1; $i<$row; $i++)
{
if (!$newsid || $newsid=="")
echo "There are no news updates.";
else
{
$conn = db_connect();
// When $i = 1, $row = 0. This SHOULD put the most recent entry first.
$query = "select * from news where newsid=($row - ($i - 1))";
$result = @mysql_query($query);
if (!$result)
echo "There are no news updates.";
else
$result = @mysql_fetch_array($result);
}
if (is_array($result))
{
echo $result["headline"]."<br>";
echo $result["content"]."<br>";
echo "<i>Posted by ".$result["author"]." on ".$result["date"].".</i>";
}
else
echo "There are no news items to display.";
}
echo "</body></html>";
?>
http://www.lastchancegames.com/main/index.php
Warning: mysql_pconnect() [function.mysql-pconnect]: Protocol mismatch. Server Version = 13 Client Version = 10 in c:\users\sitedata\lcgsteve\web\main\index.php on line 6
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in c:\users\sitedata\lcgsteve\web\main\index.php on line 7
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in c:\users\sitedata\lcgsteve\web\main\index.php on line 11
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\users\sitedata\lcgsteve\web\main\index.php on line 12
Now you should know, there is absolutely NOTHING important on this site right now. So if you want to see the back end of how things work (I host on Seanic.net), I'm able to provide a username & password, providing you don't block me out of my own site! I just want this thing fixed with a better understanding about how this stuff works.
THANK YOU!!!
- EDIT * I have changed pconnect to connect, but I am still getting the same error.