ammetto la mia noobbiagine armai lantente da molti mesi che pratico il PHP in diverse forme, ma stavolta tocco il fondo.
Non riesco a connettermi al DB per estrapolare e pubblicare le news in una pagina PHP.
Questo è il mio connect
codice:
// DATABASE - PARAMETER
//-----------------------
// Database connect
// MySQL server hostname
$dbhost = "xx.xxx.xxx.xx";
// MySQL server username
$dbuser = "xxxxxxx";
// MySQL server password
$dbpasswd = "xxxxxxxx";
// MySQL server connect
$db=@mysql_connect($dbhost,$dbuser,$dbpasswd);
// MySQL database name
$db_name="xxxxxxxxx";
@mysql_select_db($db_name,$db);
// Here you can modify the Tablenames if you like to
$table_news = "xxxxxxxxxxx";
La Query nella pagina dove pubblicare la news:
codice:
<?php
$connect = mysql_connect($dbhost, $dbuser, $dbpasswd) or die ("Non connesso");
mysql_select_db($db_name);
//@mysql_query ("select * FROM $table_news ORDER BY uid DESC LIMIT 1);
//$num = @mysql_num_rows($result);
$query = "SELECT * FROM $table_news ORDER BY uid DESC LIMIT 1";
$esegui = mysql_query($query, $connect);
//nuova
echo $table_news;
//$result=mysql_query($query);
while ($result = mysql_fetch_array($esegui)) {
echo "<div class=title style=padding-left:62px;padding-top:10px;padding-right:5px;color:#ffffff;>
$result[news_title]
</div>
</td>
</tr>
<tr>
<td width=502 height=250 background=http://www.xxxxxxxxxxx/bg02.jpg valign=top>
<table width=480 height=200 cellspacing=2 cellpadding=2 border=0>
<tr>
<td valign=top align=left>
<div style=padding-left:20px;padding-top:10px;padding-right:5px;color:#ffffff; align=justify>
$result[news_short]
$result[news_long]";
}
?>
</div>
</td>
</tr>
</table>
L'errore è il seguente:
codice:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /web/htdocs/www.xxxxxxxxx/index.php on line 124
dove la riga 124 è la seguente:
codice:
while ($result = mysql_fetch_array($esegui)) {
HELP ME!