pfkdesign Posted July 23, 2008 Share Posted July 23, 2008 hi everybody, i made get_menu_id function : <?php function get_menu_id($menu) { $result = mysql_query("SHOW TABLE STATUS LIKE 'menu'"); $rows = mysql_fetch_assoc($result); return $rows['auto_increment']; } echo get_menu_id() ?> this is return the next auto_increment id in the mysql table (5.0.5a), PROBLEM ! when i check it on local server(localhost) i dont have any problem and i 'm getting the next id , but as soon as i upload in my server i will get the warning. here are the warning: Warning: Missing argument 1 for get_menu_id(), Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource any idea? tnx Quote Link to comment https://forums.phpfreaks.com/topic/116181-solved-get-next-id-in-mysql/ Share on other sites More sharing options...
paul2463 Posted July 23, 2008 Share Posted July 23, 2008 when you wrote the function you stipulated that you would supply it with $menu function get_menu_id($menu) { and when you call it you dont give it that information echo get_menu_id() it fails because it wants to know what $menu is, you dont use it in the function anyway so I am confused as to why you want it Quote Link to comment https://forums.phpfreaks.com/topic/116181-solved-get-next-id-in-mysql/#findComment-597445 Share on other sites More sharing options...
pfkdesign Posted July 23, 2008 Author Share Posted July 23, 2008 than you paul2463 for you reply , the first warning is solved but still i have this warning : Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource... in local server (localhost) is not show up , but in main server is shewing this warning! any idea? Quote Link to comment https://forums.phpfreaks.com/topic/116181-solved-get-next-id-in-mysql/#findComment-597458 Share on other sites More sharing options...
JasonLewis Posted July 23, 2008 Share Posted July 23, 2008 Make this: $result = mysql_query("SHOW TABLE STATUS LIKE 'menu'"); This: $result = mysql_query("SHOW TABLE STATUS LIKE 'menu'") or die("Error: ".mysql_error()); Also, does the 'menu' in the query need to be the variable $menu? Quote Link to comment https://forums.phpfreaks.com/topic/116181-solved-get-next-id-in-mysql/#findComment-597459 Share on other sites More sharing options...
pfkdesign Posted July 24, 2008 Author Share Posted July 24, 2008 tnx it solved. Quote Link to comment https://forums.phpfreaks.com/topic/116181-solved-get-next-id-in-mysql/#findComment-598260 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.