I2aTe Posted July 5, 2011 Share Posted July 5, 2011 i need help fixing this please here is the file...... iv put where the error is in red. <?php include("ch21_include.php"); doDB(); if ((!$_POST["topic_owner"]) || (!$_POST["topic_title"]) || (!$_POST["post_text"])) { header ("location: addtopic.html"); exit; } $add_topic = "INSERT INTO forum_topics (topic_title, topic_create_time, topic_owner) VALUES ('".$_POST["topic_title"]."' ,now(), '".$_POST["topic_owner"]."')"; $add_topic_res = mysqli_query($mysqli, $add_topic_sql) or die(mysqli_error($mysqli)); $topic_id = mysqli_insert_id($mysqli); $add_post_sql = "INSERT INTO forum_posts (topic_id,post_text, post_create_time, post_owner) VALUES ('".$topic_id."', '".$_POST["post_text"]."', now(), '".$_POST["topic_owner"]."')"; $add_post_res = mysqli_query($mysqli, $add_post_sql) or die(mysqli_error($mysqli)); mysqli_close($mysqli); $display_block = "<p>The<strong>" .$_POST["topic_title"]."</strong> topic has been created.</p>"; ?> <html> <head> <title>New Topic Added</title> </head> <body> <h1>New Topic Added</h1> <?php echo $display_block; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/241128-warning-mysqli_query-functionmysqli-query-empty-query-in-homea3165211p/ Share on other sites More sharing options...
AyKay47 Posted July 5, 2011 Share Posted July 5, 2011 you have assigned your query to the variable $add_topic, whereas in your mysqli_query() function, you have used $add_topic_sql...change to <?php $add_topic_res = mysqli_query($mysqli, $add_topic) or die(mysqli_error($mysqli)); ?> Quote Link to comment https://forums.phpfreaks.com/topic/241128-warning-mysqli_query-functionmysqli-query-empty-query-in-homea3165211p/#findComment-1238533 Share on other sites More sharing options...
I2aTe Posted July 5, 2011 Author Share Posted July 5, 2011 its working now thankyou:) Quote Link to comment https://forums.phpfreaks.com/topic/241128-warning-mysqli_query-functionmysqli-query-empty-query-in-homea3165211p/#findComment-1238535 Share on other sites More sharing options...
I2aTe Posted July 5, 2011 Author Share Posted July 5, 2011 but now when i create a topic and go to the page to view it it says Column count of mysql.proc is wrong. Expected 20, found 16. Created with MySQL 50091, now running 50157. Please use mysql_upgrade to fix this error.?? Quote Link to comment https://forums.phpfreaks.com/topic/241128-warning-mysqli_query-functionmysqli-query-empty-query-in-homea3165211p/#findComment-1238538 Share on other sites More sharing options...
AyKay47 Posted July 5, 2011 Share Posted July 5, 2011 yes looks like your mysql server is running a newer version..you will need to run mysql_upgrade on your db...look here Quote Link to comment https://forums.phpfreaks.com/topic/241128-warning-mysqli_query-functionmysqli-query-empty-query-in-homea3165211p/#findComment-1238541 Share on other sites More sharing options...
I2aTe Posted July 5, 2011 Author Share Posted July 5, 2011 i dont get it? iv been on the website how does this help?:/ thankyou Quote Link to comment https://forums.phpfreaks.com/topic/241128-warning-mysqli_query-functionmysqli-query-empty-query-in-homea3165211p/#findComment-1238545 Share on other sites More sharing options...
AyKay47 Posted July 5, 2011 Share Posted July 5, 2011 i dont get it? iv been on the website how does this help?:/ thankyou shows you what you need to do, step-by-step Quote Link to comment https://forums.phpfreaks.com/topic/241128-warning-mysqli_query-functionmysqli-query-empty-query-in-homea3165211p/#findComment-1238547 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.