My web page was working fine last week and when I went to work on it again I got this:
Notice: Undefined index: courseID in C:\wamp\www\1.1\lib\ on line 7

Notice: Trying to get property of non-object in C:\wamp\www\1.1\lib\ on line 10
we have no data

Here is my


class coursePage extends webPage {
	protected function content() {
		$courseID = $_GET['courseID'];
		$query = "SELECT * FROM courses WHERE courseID=$courseID";
		$result  = query($query);
		if($result->num_rows > 0) {
			$temp = $result->fetch_assoc();
		else {
			echo "we have no data";

Any Ideas?

You're getting the value courseID from the URL. If this value isn't set, you'll get the notice you're seeing.

To overcome this, you could use:

$courseID = ( isset( $_GET['courseID'] ) ? $_GET['courseID'] : 0 );

This is basically an if - else statement in one line if you've not seen it before. Otherwise known as a ternary operator.



Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.