View Full Version : [PHP] Undefined index ???
Traxsung
29-01-2006, 21:07
Cosa significa questo messaggio di errore datomi dal Browser provando uno script php in localo con Easyphp ??
Se può essere utile riporto il listato:
if ($_GET["day"]!="" || $_GET["month"]!="" || $_GET["year"]!=""){
if ($_GET["day"]!=""){
$day = $_GET["day"];
} else {
$day = "";
}
if ($_GET["month"]!=""){
$month = $_GET["month"];
} else {
$month = $date_today["mon"];
}
if ($_GET["year"]!=""){
$year = $_GET["year"];
} else {
$year = $date_today["year"];
}
L'errore me lo da per day, month e year :muro:
Traxsung
29-01-2006, 21:39
mmm.... hai ragione, così non si capisce un granchè.
Ecco l'intero codice:
*/
// database functions
function show_error()
{
die("Error " . mysql_errno() . " : " . mysql_error());
}
function sql_quote($input)
{
return "'".$input."'";
}
function db_connect()
{
global $db_server;
global $db_username;
global $db_password;
global $db_name;
$con = mysql_connect($db_server,$db_username,$db_password);
if (!(mysql_select_db($db_name,$con)))
{
show_error();
}
return $con;
}
function db_disconnect($con)
{
close($con);
}
function db_prepare(){
global $viewmode;
global $day;
global $month;
global $year;
global $list_rows;
global $view_rows;
global $view_comment_rows;
global $viewcomments;
// connect to the database
$con = db_connect();
$blogid="";
$date_today = getdate();
// work out what to show based on URL parameters
;
if ($_POST["blogid"]!="") {
$blogid = $_GET["blogid"];
// get the blog entry from the database to find out what month it was (for the list and view sql)
$sql_findmonth = "SELECT *,MONTH(dEntryDate) AS month,YEAR(dEntryDate) AS year FROM blog WHERE nIdCode=".$blogid;
$result = mysql_query($sql_findmonth,$con);
if ($result!=false) {
$row = mysql_fetch_array($result);
$month = $row["month"];
$year = $row["year"];
} else {
// revert to nothing sent
$blogid="";
}
$sql_list = "SELECT * FROM blog WHERE MONTH(dEntryDate)=".$month." ORDER BY dEntryDate DESC;";
if ($viewmode=="single"){
$sql_view = "SELECT * FROM blog WHERE nIdCode=".$_GET["blogid"].";";
} else {
$sql_view = "SELECT * FROM blog WHERE MONTH(dEntryDate)=".$month." ORDER BY dEntryDate DESC;";
}
}
if ($blogid=="") {
// Figure out what parts of the date we have got
if ($_GET['day']!="" || $_GET['month']!="" || $_GET['year']!=""){
if ($_GET['day']!=""){
$day = $_GET['day'];
} else {
$day = "";
}
if ($_GET["month"]!=""){
$month = $_GET["month"];
} else {
$month = $date_today["mon"];
}
if ($_GET["year"]!=""){
$year = $_GET["year"];
} else {
$year = $date_today["year"];
}
} else {
$day = "";
$month = $date_today["mon"];
$year = $date_today["year"];
}
// Build the SQL statements
if ($day!=""){
$sql_list = "SELECT * FROM blog WHERE MONTH(dEntryDate)=".$month." AND YEAR(dEntryDate)=".$year." AND DAYOFMONTH(dEntryDate)=".$day." ORDER BY nIdCode DESC;";
if ($viewmode == "single"){
$sql_view = "SELECT * FROM blog WHERE MONTH(dEntryDate)=".$month." AND YEAR(dEntryDate)=".$year." AND DAYOFMONTH(dEntryDate)=".$day." ORDER BY nIdCode DESC;";
} else {
$sql_view = "SELECT * FROM blog WHERE MONTH(dEntryDate)=".$month." AND YEAR(dEntryDate)=".$year." ORDER BY nIdCode DESC;";
}
} else {
$sql_list = "SELECT * FROM blog WHERE MONTH(dEntryDate)=".$month." AND YEAR(dEntryDate)=".$year." ORDER BY nIdCode DESC;";
if ($viewmode == "single"){
$sql_view = "SELECT * FROM blog WHERE MONTH(dEntryDate)=".$month." AND YEAR(dEntryDate)=".$year." ORDER BY nIdCode DESC LIMIT 1;";
} else {
$sql_view = "SELECT * FROM blog WHERE MONTH(dEntryDate)=".$month." AND YEAR(dEntryDate)=".$year." ORDER BY nIdCode DESC;";
}
}
}
// Get data from the database (store in arrays)
$list_result = mysql_query($sql_list,$con);
$view_result = mysql_query($sql_view,$con);
// Build List Array
if ($list_result!=false) {
$i=0;
while ($list_row =@ mysql_fetch_array($list_result)){
$i++;
$list_rows[$i] = $list_row;
}
} else {
$problem = "1";
}
// Build View Array
if ($view_result!=false) {
$i=0;
while ($view_row =@ mysql_fetch_array($view_result)){
$i++;
$view_rows[$i] = $view_row;
// build view_comments array
if ($viewcomments=="yes") {
$sql = "SELECT * FROM blog_comments WHERE nBlogId=".$view_row["nIdCode"]." ORDER BY nIdCode DESC";
$result = mysql_query($sql,$con);
if ($result!=false){
$j=0;
while ($comment_row =@ mysql_fetch_array($result)){
$j++;
$view_comment_rows[$i][$j] = $comment_row;
}
}
}
}
} else {
$problem = "2";
}
// increment view counter for either the single blog being shown
// or ALL blogs being shown
if ($view_rows[1]["nIdCode"]!=""){
if ($viewmode=="single"){
$blogid = $view_rows[1]["nIdCode"];
$sql = "UPDATE blog SET nViews=nViews+1 WHERE nIdCode=".$blogid;
} else {
for ($i=1;$i<=count($view_rows);$i++){
$blog_array[$i] = $view_rows[$i]["nIdCode"];
}
$blogids = implode(",",$blog_array);
$sql = "UPDATE blog SET nViews=nViews+1 WHERE nIdCode IN (".$blogids.")";
}
$result = mysql_query($sql,$con);
if ($result==false){
print "<li>Problem with SQL<br>[".$sql."]</li>\n";
}
}
}
function db_hitcount(){
$con = db_connect();
$sql = "SELECT SUM(nViews) AS nTotal FROM blog";
$result = mysql_query($sql,$con);
if ($result!=false){
$row = mysql_fetch_array($result);
$total = $row["nTotal"];
} else {
$total = 0;
}
return $total;
}
?>
Ah... ti ricordo che lo sto testando in locale :D
Traxsung
30-01-2006, 19:40
dai ragazzi.... ho bisogno urgentemente di un'aiuto :cry:
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.