silverglade Posted August 5, 2008 Share Posted August 5, 2008 i tried to load the first page of my forum that i put in the wwwroot directory of my hosted server, where the ******* are i put in my phpadmin user and password, the page gives me the error. Fatal error: Call to undefined function mysql_connect() in D:\Inetpub\virtual\brendansite1\WWWROOT\main_forum.php on line 9 here is the code to the main page of my forum, any help greatly appreciated, thanks. i think it has to do with line nine. hehe. <?php $host="localhost"; // Host name $username="********"; // Mysql username $password="*********"; // Mysql password $db_name="brendansite1"; // Database name $tbl_name="forum_question"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name ORDER BY id DESC"; // OREDER BY id DESC is order result by descending $result=mysql_query($sql); ?> <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td> <td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td> <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ // Start looping table row ?> <tr> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['reply']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td> </tr> <?php // Exit looping and close connection } mysql_close(); ?> <tr> <td colspan="5" align="right" bgcolor="#E6E6E6"><a href="create_topic.php"><strong>Create New Topic</strong> </a></td> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/118251-phpmysql-forum-im-making-not-working/ Share on other sites More sharing options...
mbeals Posted August 5, 2008 Share Posted August 5, 2008 let me guess, php5 on a windows machine? the mysql libraries are not included with php5. You need to manually install them. I was actually fighting this last night and couldn't find a resolution (although I didn't try that long) so hopefully someone will give a solution. Link to comment https://forums.phpfreaks.com/topic/118251-phpmysql-forum-im-making-not-working/#findComment-608552 Share on other sites More sharing options...
ngreenwood6 Posted August 5, 2008 Share Posted August 5, 2008 Are you on your local machine? If so I would check out wamp or xxamp. Comes with php, apache, mysql, and phpmyadmin already embedded into. Link to comment https://forums.phpfreaks.com/topic/118251-phpmysql-forum-im-making-not-working/#findComment-608555 Share on other sites More sharing options...
silverglade Posted August 5, 2008 Author Share Posted August 5, 2008 the files and mysql are on my hosted web server and should work automatically. could it be because mysql on the server automatically chooses swedish for the table collation? Link to comment https://forums.phpfreaks.com/topic/118251-phpmysql-forum-im-making-not-working/#findComment-608557 Share on other sites More sharing options...
silverglade Posted August 6, 2008 Author Share Posted August 6, 2008 i altered the code a little on the top, and i get the following error when trying to connect to the database with this page. Warning: mysql_connect() [function.mysql-connect]: Access denied for user: 'brendansite1@localhost' (Using password: YES) in D:\Inetpub\virtual\brendansite1\WWWROOT\main_forum.php on line 10 cannot connect here is the code, any help greatly appreciated. thank you. derek i put ****** where my user and password is for this post. <?php dl("php_mysql.dll"); $host="localhost"; // Host name $username="*********"; // Mysql username $password="**********"; // Mysql password $db_name="brendansite1"; // Database name $tbl_name="forum_question"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name ORDER BY id DESC"; // OREDER BY id DESC is order result by descending $result=mysql_query($sql); ?> <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td> <td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td> <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ // Start looping table row ?> <tr> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['reply']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td> </tr> <?php // Exit looping and close connection } mysql_close(); ?> <tr> <td colspan="5" align="right" bgcolor="#E6E6E6"><a href="create_topic.php"><strong>Create New Topic</strong> </a></td> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/118251-phpmysql-forum-im-making-not-working/#findComment-609602 Share on other sites More sharing options...
silverglade Posted August 6, 2008 Author Share Posted August 6, 2008 always check with your hosting provider for answers if you cant get them in the forum. i got my PHP discussion forum up at the following link!!!! YES!!! http://derekvanderven.com/main_forum.php my hosting provider technical support answered my questions and i got my board up. sweet. thank you. derek Link to comment https://forums.phpfreaks.com/topic/118251-phpmysql-forum-im-making-not-working/#findComment-609981 Share on other sites More sharing options...
Third_Degree Posted August 6, 2008 Share Posted August 6, 2008 always check with your hosting provider for answers if you cant get them in the forum. i got my PHP discussion forum up at the following link!!!! YES!!! http://derekvanderven.com/main_forum.php my hosting provider technical support answered my questions and i got my board up. sweet. thank you. derek A little plain, but good for a first forum. Link to comment https://forums.phpfreaks.com/topic/118251-phpmysql-forum-im-making-not-working/#findComment-609982 Share on other sites More sharing options...
silverglade Posted August 6, 2008 Author Share Posted August 6, 2008 haha ya it is plain, but thank you for the compliment. it is my first. thanks. derek Link to comment https://forums.phpfreaks.com/topic/118251-phpmysql-forum-im-making-not-working/#findComment-609988 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.