newbie_do Posted February 9, 2014 Share Posted February 9, 2014 (edited) Hey guys I'm a student just studying PHP, I'm trying to make a newspage and I'm having this error in my code, can anyone help me with this code? <html><body> <div align="center"> <? include("atas.php");?> <table width="460" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" > <tr> <td width="460" bgcolor="#EAECCA" p align=center> <? include("./SDB.php"); $db_name=""; $hasil = mysql_query($db_name,"SELECT * FROM news order by id desc"); while ($data = mysql_fetch_row($hasil)) { $id=$data[0]; $tanggal=$data[1]; $judul=$data[2]; $isi=$data[3]; $foto=$data[4]; $penulis=$data[5]; ?><BR><? echo"<img src='./image/$foto' width=100 height=125align=Left>"; ?><p align=justify><font color=#0C4BAB><b><? echo $judul; ?></b></font><BR>Oleh:<font color=blue><? echo($penulis);?></font><BR><? echo $tanggal; ?><BR><? echo $isi; ?><BR><BR><BR><BR><?}?></td></tr><tr><td width="460" bgcolor="#00428C"></td></tr></table><BR><? include("link.php");?></div></body></html> lihat_detail.php Edited February 9, 2014 by newbie_do Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted February 9, 2014 Share Posted February 9, 2014 (edited) since this is not ms sql, moving to the php help forum (your problem is the usage of the php functions, not the actual query, yet). you should also be getting a warning/error message for the mysql_query() statement, it is the cause of the error you did post. when php functions are supplied with invalid parameters, they return null values now. there's three problems with the mysql_query() statement in that code - 1) the order of the parameters for mysql_query() are - ($query , $link_identifier) 2) you are putting an empty string into a variable named $db_name and putting that into the mysql_query() statement. that makes no sense. the database name belongs in a select_db statement or in the actual sql query statement. it is not a parameter in any type of current query() statement. 3) the msyql (no i on the end) functions are depreciated. you should be using mysqli or pdo functions so that you don't have to rewrite your code at some point in the future. Edited February 9, 2014 by mac_gyver Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.