Saving data MySQL PHP

  • Posted January 18, 2014

I am trying to save some data from my website to my database. This works on both my local machine and thorugh my student host:

some php…

$connection = @mysqli_connect('localhost', 'username', 'pw') 
    or die (mysqli_error()); 
mysqli_select_db($connection, 'mydatabase') 
    or die (mysqli_error()); 

some php…

I have followed all the instruction from:


So i have php and mysql installed and I can access my databases through phpmyadmin

I still can’t save data to the database through my website using the script listed above.

Any idea what might be the problem?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Solved… :) thanks Darius. You made focus on another part of code

Your code doesnt show any form of INSERT query. The code you simply provided just connects and selects the db and if theres an error to “die” with the error message showing.