hm_ncsm Posted July 28, 2016 Share Posted July 28, 2016 hello every body hop to have a good day my friends I have a site based on wordpress that I get author id and post id by following codes : <؟phpecho (the_author_meta('ID') ); //author idecho (get_post_field('ID', $post_id)) ;//post id?> now I want save this details in other data base but I cant who know true Answer?? ... by the way I must say that I try to save that details on new data base by this way : <?php $one = the_author_meta('ID') ; $two = get_post_field('ID', $post_id) $con = mysqli_connect('localhost','hm','123','user'); $res = mysqli_query($con,"insert into db (col1,col2) values ('$one','$two') "); ?> but not work Quote Link to comment https://forums.phpfreaks.com/topic/301677-save-wordpres-information-in-new-database-using-wp-shortcodes/ Share on other sites More sharing options...
Barand Posted July 28, 2016 Share Posted July 28, 2016 After the mysqli_query line, add if (!$res) echo $con->error; That should tell you why. Quote Link to comment https://forums.phpfreaks.com/topic/301677-save-wordpres-information-in-new-database-using-wp-shortcodes/#findComment-1535247 Share on other sites More sharing options...
hm_ncsm Posted July 28, 2016 Author Share Posted July 28, 2016 tnx man ! but my problem dont relate to mysqli and way to connect , I successfully connetct to db and also insert my data but in that 2 rows insert NULL Quote Link to comment https://forums.phpfreaks.com/topic/301677-save-wordpres-information-in-new-database-using-wp-shortcodes/#findComment-1535248 Share on other sites More sharing options...
Jacques1 Posted July 31, 2016 Share Posted July 31, 2016 Then why didn't you say that? Learn how to issue dynamic queries and try again. It also helps to var_dump() the values right before the query so that you know what's being sent to the database system. Quote Link to comment https://forums.phpfreaks.com/topic/301677-save-wordpres-information-in-new-database-using-wp-shortcodes/#findComment-1535345 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.