Jump to content

Recommended Posts

im getting this notices

 

Strict Standards: main() [function.main]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead in /home/ecabrera/public_html/addvideo.php on line 54

 

Notice: Undefined index: addbtn in /home/ecabrera/public_html/addvideo.php on line 54

 

 

if ($_POST['addbtn']){

 

if ($_POST['addbtn']){
		$title = $_POST['title'];
		$description = $_POST['description'];
		$keywords = $_POST['keywords'];
		$category = $_POST['category'];
		$videoid = $_POST['videoid'];

		if ($title){
		if ($description){
		if ($keywords){
		if ($category){
		if ($videoid){
			if (strstr($categories, "<option value='$category'>$category</option>")){
				require("scripts/connect.php");

				$query = mysql_query("SELECT * FROM videos WHERE videoid='$videoid'");
				$numrows = mysql_num_rows($query);
				if ($numrows == 0){

					$date = date("F d, Y"); // October 09, 2010
					mysql_query("INSERT INTO videos VALUES ('', '$userid', '$username', '$title', '$description', '$keywords', '$category', '$videoid', '0', '$date')");
					$query = mysql_query("SELECT * FROM videos WHERE user_id='$userid' AND title='$title' AND videoid='$videoid'");
					$numrows = mysql_num_rows($query);
					if ($numrows == 1){
						$row = mysql_fetch_assoc($query);
						$id = $row['id'];

						echo "Your video has been added. <a href='$site/videos?id=$id'>Click here to view it.</a>";

					}
					else
						echo "<font color='red'>Your video was not added to the database for some reason.</font>";
				}
				else
					echo "You can not add a video that is already in the database. $form";

				mysql_close();
			}
			else
				echo "You did not submit a valid category. $form";
		}
		else
			echo "You did not submit a video ID. $form";
		}
		else
		echo "You did not select a category. $form";
		}
		else
		echo "You did not submit any keywords. $form";
		}
		else
		echo "You did not submit a description. $form";
		}
		else
			echo "You did not submit a title. $form";
	}
	else
		echo "$form";

}
else
	echo "<h2><font color='red'>You must be logged in to add a video.</font></h2>";

?>
</div>

Link to comment
https://forums.phpfreaks.com/topic/243811-notice-help/
Share on other sites

use

if(@$_POST['addbtn']){

to suppress the notice on the variable existance check.

 

Update your timezone in your php.ini file so that it is set to your servers locatation.  There are plenty step by trep guides out there just google if you need one.

i wouldn't recommend using the @ suppresor in this case simply because it is a bad habit to get into, however I do agree that you should adjust the default timezone in your php.ini file to avoid having to manually change it in all of your files..

Link to comment
https://forums.phpfreaks.com/topic/243811-notice-help/#findComment-1251779
Share on other sites

TBH, it's about the only time I will support it's use.  It's when people start suppressing errors I get a bit nervous.

remember that the majority of people that come here are amateurs at coding, if you tell them to use the @ suppressor here, they are more then likely to start using it everytime that don't want to see an error..which in itself can cause many more errors and missed errors..

Link to comment
https://forums.phpfreaks.com/topic/243811-notice-help/#findComment-1251788
Share on other sites

@AyKay47 (and I don't meen that I am trying to suppress you :P) I appreciate what you are saying, I just have faith that people will keep learning about the new things they are shown :D

 

@ecabrera it depends on what your notices are.  most production servers have notices turned off in the php.ini display_error setting, but some of them can point to potentialy significant problems with your code - perticularly anything that has the word "depreciated" in it.

Link to comment
https://forums.phpfreaks.com/topic/243811-notice-help/#findComment-1251791
Share on other sites

i change the time setting and 50% of my notices disappear

 

heres or others

 

Notice: Undefined index: commentbtn in /home/ecabrera/public_html/videos.php on line 99

 

if ($_POST['commentbtn']){

 

Notice: Undefined index: s in /home/ecabrera/public_html/videos.php on line 138

$start = $_GET['s'];

 

Notice: Undefined index: comment in /home/ecabrera/public_html/videos.php on line 152

$comment = ($row['comment']);

 

Notice: Undefined variable: msg in /home/ecabrera/public_html/videos.php on line 179

 

echo "<b>$msg</b><br />";

 

 

			// comment button action
		if ($_POST['commentbtn']){
			$comment = $_POST['comment'];

			if ($comment){
				if ($userid != $getid){
					$query = mysql_query("SELECT * FROM video_comments WHERE video_id='$getid' AND user_id='$userid' AND comment='$comment'");
					$numerows =mysql_num_rows($query);
					if ($numrows != 0){
						$commdate = date("F d, Y"); // October 08, 2010
						mysql_query("INSERT INTO video_comments VALUES ('', '$getid', '$userid', '$username', '$comment', '$commdate')");

						// email profile owner
						$webmaster = "admin@maliferulez.com";
						$headers = "From: Ma Life Rulez<$webmaster>";
						$subject = "$username has commented on your profile";
						$message = "Hello $firstname $lastname. $username has posted a comment on your you video titled \"$title\" on maliferulez.com";
						$message .= " The message $username has posted with is below.\n";
						$message .= "\n****************************************************************\n";
						$message .= "$comment";
						$message .= "\n\n****************************************************************\n\n";
						$message .= "Click here to view $username's profile $site/profile?id=$userid\n";
						$message .= "Click here to view your video $site/videos?id=$getid\n";
						// send email
						mail($email, $subject, $message, $headers);

						$msg = "Your comment has been added and is shown above.";
					}
					else
						$msg = "You can not submit the same comment twice.";
				}
				else
					$msg = "You can not comment on your own video.";
			}
			else
				$msg = "You did not supply a comment.";
		}

		// display comments
		$perpage = 10;
		$start = $_GET['s'];
		if (!$start)
			$start = 0;

		$query = mysql_query("SELECT * FROM video_comments WHERE video_id='$getid' ORDER BY id DESC LIMIT $start, $perpage");
		$numrows = mysql_num_rows($query);
		if ($numrows > 0){

			$next = $start + $perpage;
			$prev = $start - $perpage;

			while($row = mysql_fetch_assoc($query)){
				$user_id = $row['user_id'];
				$user_name = $row['user_name'];
				$comment = ($row['comment']);
				$date = $row['date'];

				echo "<b>Posted by <a href='$site/profile?id=$user_id'>$user_name</a> on $date</b><br />";
				echo "<div style='margin-left: 10px;'>$comment</div><hr>";

			}
		}
		else
			echo "This video has no comments.<br />";
		// end diplay comment area

		// show comment nav
		echo "<div style='float: right;'>";

		if (!($start <= 0))
			echo "<a href='$site/videos?id=$getid&s=$prev#comments'>Previous</a>";

		if (!($start > $numrows - $perpage))
			echo "<a href='$site/videos?id=$getid&s=$next#comments'>Next</a>";

		echo "</div>";

		if ($username){
			// display comment form
			echo "<a name='comment-form'></a>";
			if ($msg)
				echo "<b>$msg</b><br />";

			echo "<form action='$site/videos?id=$getid#comment-form' method='post'>
			<table>
			<tr>
				<td><textarea name='comment' style='width: 400px; height: 75px;'></textarea></td>
			</tr>
			<tr>
				<td><input type='submit' name='commentbtn' value='Comment'></td>
			</tr>
			</table>
			</form>";
		}

		// end comment box
		echo "</div>

		  <b class='corners'>
		  <b class='corners5'></b>
		  <b class='corners4'></b>
		  <b class='corners3'></b>
		  <b class='corners2'><b></b></b>
		  <b class='corners1'><b></b></b></b>
		</div>";

		// end comment section

		echo "</div>";
		// end left column

	}
	else
		echo "The video you were looking for was not found.";

	// end full and video
	echo "</div>";
	echo "</div>";
}
else{
	echo "<div id='left'>";

	$perpage = 10;
if(@$_GET['s']){
$start = $_GET['s'];
}
else{
$start = 0;
}

	$next = $start + $perpage;
	$prev = $start - $perpage;

	$query = mysql_query("SELECT * FROM videos ORDER BY id DESC");
	$numrows = mysql_num_rows($query);
	if ($numrows > 0){
		$query = mysql_query("SELECT * FROM videos ORDER BY id DESC LIMIT $start, $perpage");

		// show comment nav
		echo "<center><div class='pagination'>";

		if (!($start <= 0))
			echo "<a href='$site/videos?s=$prev'>Previous</a>";

		/*
		$x = 1;
		for ($i = 0; $i < $numrows; $i += $perpage){
			if ($start != $i)
				echo "<a href='$site/videos?s=$i'>$x</a>";
			else
				echo "<a href='$site/videos?s=$i'><b><u>$x</u></b></a>";
			$x++;
		}
		*/

		if (!($start > $numrows - $perpage))
			echo "<a href='$site/videos?s=$next'>Next</a>";

		echo "</div></center><br />";

		while ($row = mysql_fetch_assoc($query)){
			$id = $row['id'];
			$user_id = $row['user_id'];
			$user_name = $row['user_name'];
			$title = $row['title'];
			$description = $row['description'];
			$keywords = $row['keywords'];
			$category = $row['category'];
			$videoid = $row['videoid'];
			$views = $row['views'];
			$comments = $row['comments'];
			$date = $row['date'];

			//$description = $description.$description.$description;

			if (strlen($description) >= 100)
				$description = substr($description, 0, 100)."...";

			echo "<div class='video'>
				<div class='image'><a href='$site/videos?id=$id'><img src='http://i1.ytimg.com/vi/$videoid/default.jpg'></img></a></div>
				<div class='info'>
					<div class='title'><a href='$site/videos?id=$id'>$title</a></div>
					<div class='description'>
						$description
						<br /><br />
						<div style='float: left; font-size: 16px;'><a href='$site/profile?id=$user_id'>$user_name</a></div>
						<div style='float: right; font-size: 16px;'>$category</div>
						<center>$views views</center>
					</div>
				</div>
			</div>";

		}

		// show comment nav
		echo "<div class='clear'></div>";
		echo "<center><div class='pagination'>";

		if (!($start <= 0))
			echo "<a href='$site/videos?s=$prev'>Previous</a>";

		if (!($start > $numrows - $perpage))
			echo "<a href='$site/videos?s=$next'>Next</a>";

		echo "</div></center>";

	}
	else
		echo "There currently are no videos.";


	echo"</div>";
}

mysql_close();
?>

 

Link to comment
https://forums.phpfreaks.com/topic/243811-notice-help/#findComment-1251795
Share on other sites

the undefined index notices will not hinder your script, however they should ebe addressed, bascially it is telling you that the indices of the given arrays do not have values, this is becuase you are not checking if they are set first before initiating them..as for the undefined variable error, you are setting the variable inside of a coinditional statement, then trying to echo the contents..most likely the $msg variable is not getting set to a value before you are trying to output its value

Link to comment
https://forums.phpfreaks.com/topic/243811-notice-help/#findComment-1251810
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.