Jump to content
Sign in to follow this  

adding a record to a table

Recommended Posts

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,



Share this post

Link to post
Share on other sites

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.

Share this post

Link to post
Share on other sites

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!

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.