barranco_bob Posted February 7, 2008 Share Posted February 7, 2008 I've moved servers and thought i'd reconfigured all of the required files but although the site mostly works and defineately links to mysql databse i'm getting : Notice: Undefined index: agent_ref in /home/......./htdocs/property/index.php on line 9 - and similar all over the place. I was getting Undefined Variable messages but got rid of these by opening the file then saving and reloading! Don't know why but it worked!! typical of the problem is below. Please tell me I am a fool and it'll take 10 seconds to fix!!! <?php ////////////////////////////////////////// $page_cat="property"; $page_title="Advanced Property Search"; $msg_var=$_GET["agent_ref"]; // ******** this is line 9 ******** ////////////////////////////////////////// require_once($_SERVER['DOCUMENT_ROOT']."/includes/header.inc.php"); require_once($_SERVER['DOCUMENT_ROOT']."/includes/search_options.inc.php"); //set parametres for rental and for sale searches if($_GET["type"]=="rental") { $query_type=" and rental is not null and commercial is null"; $type_desc="to rent"; }elseif($_GET["type"]=="commercial"){ $query_type=" and commercial is not null"; $type_desc="for commercial purposes"; }else{ $query_type="and rental is null and commercial is null"; $type_desc="for sale"; } //distinct agents from listing $q_agent="select distinct l.agent_id as id, count(*) as number, a.name as name from listing l, agent a where l.agent_id=a.id and l.status='live' $query_type group by a.name order by a.name"; $r_agent=mysql_query($q_agent,$conn) or die(mysql_error()); //count rows $q_count="select count(*) as 'total' from listing where status='live' $query_type group by status"; $r_count=mysql_query($q_count,$conn) or die(mysql_error()); $count_row = mysql_fetch_assoc($r_count); require_once($_SERVER['DOCUMENT_ROOT']."/includes/html_header.inc.php"); ?><body background="../images/jpegs/background_1.jpg"> <table width="100%" cellpadding="0" cellspacing="10" border="0"> <tr> <td> <!--Search fields --> <table width="100%" height="15" cellpadding="0" cellspacing="0" border="0"> <tr> <td background="/images/gifs/content_bg.gif"> <strong> Search from<font color="#E67817"> <?=$count_row["total"]?> </font>properties <?=$type_desc?> </strong> </td> </tr> </table> <form action="results.php" method="get"> <?php if($_GET["type"]){echo("<input type=\"hidden\" name=\"type\" value=\"".$_GET["type"]."\">");}?> (edited by kenrbnsn to put in tags) Quote Link to comment https://forums.phpfreaks.com/topic/89930-moved-server-getting-errors-notice-undefined-index/ Share on other sites More sharing options...
aschk Posted February 7, 2008 Share Posted February 7, 2008 You appear to have some crazy character on your first line after "php" <?phpπ and also some random font b tag [/font][/b] Quote Link to comment https://forums.phpfreaks.com/topic/89930-moved-server-getting-errors-notice-undefined-index/#findComment-461021 Share on other sites More sharing options...
barranco_bob Posted February 7, 2008 Author Share Posted February 7, 2008 strange code there just to confuse - it's only on the message - i tried to highlight the line but that just came out as tag. Quote Link to comment https://forums.phpfreaks.com/topic/89930-moved-server-getting-errors-notice-undefined-index/#findComment-461038 Share on other sites More sharing options...
trq Posted February 7, 2008 Share Posted February 7, 2008 You never check that $_GET["agent_ref"] exists prior to trying to assign its value to another variable. Take a look at isset(). Quote Link to comment https://forums.phpfreaks.com/topic/89930-moved-server-getting-errors-notice-undefined-index/#findComment-461042 Share on other sites More sharing options...
barranco_bob Posted February 8, 2008 Author Share Posted February 8, 2008 thanks thorpe - isset seems to work - doesn't seem rational to me but hey .. if it works ...... this has thrown up a couple of other problems - surely all these issues must be to do with changing server - is there no way apart from changing every instance of code? new problem is that code won't parse e.g. //set agent id search with private sale & remax if($_GET["agent"]) { $parse.="agent=".$_GET["agent"]."&"; and i'm getting message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition on l.condition=condition.id where l.listing_id='9002' at line 13 e.g. //property details if(is_numeric($_GET["id"])) { $property_q="select * from listing l left join agent on l.agent_id=agent.id left join location on l.location=location.id left join property_type on l.property_type=property_type.id left join situation on l.situation=situation.id left join construction_age on l.construction_age=construction_age.id left join pool on l.pool=pool.id left join heating on l.heating=heating.id left join road_access on l.road_access=road_access.id left join parking on l.parking=parking.id left join outside on l.outside=outside.id left join condition on l.condition=condition.id where l.listing_id='".$_GET["id"];"'"; @$property_r=mysql_query($property_q, $conn) or die(mysql_error()); if(@mysql_num_rows($property_r)=="0") { header("Location:/property/search.php?msg=1"); exit(); }else{ $result=@mysql_fetch_assoc($property_r); } neither of these is affected by addition of isset any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/89930-moved-server-getting-errors-notice-undefined-index/#findComment-461847 Share on other sites More sharing options...
TheFilmGod Posted February 8, 2008 Share Posted February 8, 2008 @$property_r=mysql_query($property_q, $conn) or die(mysql_error()); contradicts itself - like a paradox "@" makes no error come up and then you use die()? Quote Link to comment https://forums.phpfreaks.com/topic/89930-moved-server-getting-errors-notice-undefined-index/#findComment-461854 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.