GerryCarr Posted July 26, 2011 Share Posted July 26, 2011 My web hosting with 1and1 was just updated and now my php is failing and I don't know why. Heres the code: if(empty($article)){ $head_query = mysql_query("SELECT * FROM article_cats WHERE id='$page'") or die(mysql_error()); } if(empty($page)){ $head_query = mysql_query("SELECT title, `desc`, keywords FROM articles WHERE id='$article'") or die(mysql_error()); } echo(mysql_num_rows ($head_query)); while($load_info = mysql_fetch_array($head_query)){ $title = $load_info['title']; $desc = $load_info['desc']; $keywords = $load_info['keywords']; } The connection is working. echo(mysql_num_rows ($head_query)); is throwing out 0 even tho if you ran the sql, in sql it returns 1 The issue seems revolves around mysql_fetch_array Please help! Quote Link to comment https://forums.phpfreaks.com/topic/242891-dire-help-needed/ Share on other sites More sharing options...
msaz87 Posted July 26, 2011 Share Posted July 26, 2011 In the host update did they modify the DB structure at all? Maybe the table name changed if the script was working before the update and you haven't touched it since Quote Link to comment https://forums.phpfreaks.com/topic/242891-dire-help-needed/#findComment-1247588 Share on other sites More sharing options...
GerryCarr Posted July 26, 2011 Author Share Posted July 26, 2011 The SQL is 100% the same, I think it's something to do with variables being directly called from a URL string into the database? is there some new way of doing this? Quote Link to comment https://forums.phpfreaks.com/topic/242891-dire-help-needed/#findComment-1247593 Share on other sites More sharing options...
GerryCarr Posted July 26, 2011 Author Share Posted July 26, 2011 $head_query = mysql_query("SELECT * FROM article_cats WHERE id='$page'") or die(mysql_error()); Doesn't work $head_query = mysql_query("SELECT * FROM article_cats"); does work, any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/242891-dire-help-needed/#findComment-1247597 Share on other sites More sharing options...
msaz87 Posted July 26, 2011 Share Posted July 26, 2011 Where is $page being defined? Well you could check to make sure your queries are populating properly by splitting out the actual statement like this: if(empty($article)){ $head_query = "SELECT * FROM article_cats WHERE id='$page'"; echo $head_query; //$head_query_run = mysql_query($head_query) or die(mysql_error()); } This way you can at least make sure the query is being put together properly Quote Link to comment https://forums.phpfreaks.com/topic/242891-dire-help-needed/#findComment-1247599 Share on other sites More sharing options...
GerryCarr Posted July 26, 2011 Author Share Posted July 26, 2011 The query is fine. $page is in the URL website.com?page=1 Quote Link to comment https://forums.phpfreaks.com/topic/242891-dire-help-needed/#findComment-1247605 Share on other sites More sharing options...
msaz87 Posted July 26, 2011 Share Posted July 26, 2011 Try plugging in the hard value to test it. $head_query = mysql_query("SELECT * FROM article_cats WHERE id=1") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/242891-dire-help-needed/#findComment-1247606 Share on other sites More sharing options...
xyph Posted July 26, 2011 Share Posted July 26, 2011 This is a register_globals issue. Anywhere that you used $page to grab script.php?page=something tou now have to use $_GET['page'] Quote Link to comment https://forums.phpfreaks.com/topic/242891-dire-help-needed/#findComment-1247623 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.