0
 1  <?php
 2  include_once('connect_db.php');
 3  $domain = $_SERVER['HTTP_HOST'];
 4  if($domain == "localhost"){
 5      $domainx = $domain."/get-new";
 6  } else {
 7      $domainx = $domain;
 8  }
 9  $domainx = str_replace("www.", "", $domainx);
10  $query_domain_one = mysql_query("select dir_default_value from yellow_domain_details where dir_domain = '$domainx' and dir_status = 'Y' limit 1") or die(mysql_error());
11  $mysql_nums = mysql_num_rows($query_domain_one);
12  $dir_default_value_fetch = mysql_fetch_object($query_domain_one);
13  $dir_default_valued = $dir_default_value_fetch->dir_default_value;
14  if(!empty($dir_default_valued)){
15      $query_top_menu = mysql_query("select ytt_url from yellow_top_tabs where ytt_id = '$dir_default_valued' limit 1");
16  } else {
17      $query_top_menu = mysql_query("select ytt_url from yellow_top_tabs where ytt_default = 'Y' limit 1");
18  }
19  $query_top_menu_num = mysql_num_rows($query_top_menu);
20  if($query_top_menu_num > 0){
21      while($query_top_menu_rows = mysql_fetch_array($query_top_menu)){
22          extract($query_top_menu_rows);
23          if(file_exists($ytt_url)){
24              include($ytt_url);
25          } else {
26              include('new-default.php');
27          }
28      }
29  } else {
30      include('new-default.php');
31  }
32  ?>

This is my index.php

PHP Notice: Trying to get property of non-object in D:\dev2010\lb33443\mudah.my\www\index.php on line 13

Many thanks.

Lee

Mark Reed
  • 91,912
  • 16
  • 138
  • 175
Lee
  • 5
  • 2
  • 3
  • 4
    [**Please, don't use `mysql_*` functions in new code**](http://stackoverflow.com/q/12859942). [They are officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). See the [red box](http://uk.php.net/manual/en/function.mysql-connect.php)? Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement), and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this](http://php.net/manual/en/mysqlinfo.api.choosing.php) will help you decide which. If you choose PDO, [here is a good tutorial](http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers). – Joseph Silber Dec 25 '13 at 04:28
  • Debug the error by `var_dump($dir_default_value_fetch)`. – Passerby Dec 25 '13 at 04:28

2 Answers2

0

This query returned no result. so you got the error.

mysql_query("select dir_default_value from yellow_domain_details where dir_domain = '$domainx' and dir_status = 'Y' limit 1")

Before this line $dir_default_valued = $dir_default_value_fetch->dir_default_value; count no. of rows.

chanchal118
  • 3,551
  • 2
  • 26
  • 52
0

try

$dir_default_valued =($dir_default_value_fetch!==false)? $dir_default_value_fetch->dir_default_value:'';

Instead Of

$dir_default_value_fetch=$dir_default_value_fetch->dir_default_value;