ack Posted February 1, 2017 Share Posted February 1, 2017 I am trying to add a record to a table. Using previously- functional code lifted from another project, the script dies at the mysql_query() line. I have confirmed that the information to be inserted is being passed properly from the form page, that the variables and field names match and are in sequence and the coding is correct. The problem I am having in debugging is that I cannot get an explanatory error message to generate. Here is a snippet (MySQL version 5.5.43-37.2-log on a Godaddy server) $query = "INSERT INTO linkdb (keywords.category,title,link,icon,id_no) values ($inkeywords,$incategory,$intitle,$inlink,$inicon,$inid_no)";mysql_query($query) or die("error :".mysqli_error($connection)); "$connection" being the correct mysql_connect data. The error string generated by the server is: "warning: mysqli-error() expects parameter 1 to be mysqli, resource given in ......" The above line of code was adapted from page 350 of "PHP & MySQL Web Development for Dummies" by Janet Valade, whom I trust more than W3Schools... I suspect there may be a problem with the compatibility of the construction of the table and fields, but I am reluctant to change anything blindly as the table is currently in use on a website. How do I get the actual error information to appear? Your Humble servant, Ack Quote Link to comment https://forums.phpfreaks.com/topic/303077-adding-a-record-to-a-table/ Share on other sites More sharing options...
mac_gyver Posted February 1, 2017 Share Posted February 1, 2017 you cannot mix statements from the different database extensions. your database connection and query are using mysql_ statements. your error reporting is using mysqli_error(). if you were using mysql_error(), you would be getting the actual error information. next, the php mysql_ extension is obsolete and has been removed from php, for a little over a year. you need to be actively converting your code to use the php PDO extension, so that it doesn't stop entirely working should your web host up date the php version. Quote Link to comment https://forums.phpfreaks.com/topic/303077-adding-a-record-to-a-table/#findComment-1542197 Share on other sites More sharing options...
ack Posted February 2, 2017 Author Share Posted February 2, 2017 Excellent assistance, mac_gyver! removing the 'i' solved the problem - which is now obvious to me. The resulting change revealed the true problem as being syntax useage in the query string. I shall study up on the PDO extension so that my pages do not "seize up" when GoDaddy next upgrades the server software. Again, Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/303077-adding-a-record-to-a-table/#findComment-1542200 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.