How to connect to a certain table in MySQL database?
I have tried :
mysql_select_db("baybeestore",$connection);
but it gives me an error :-
"Error : Table 'baybeestore.form' doesn't exist"
But I've created a table named as order
. Are there any PHP codes to connect to my table order
in the same database that have multiple databases?
Is it wise enough to create multiple database & one table for one website or multiple table with one database?
FULL CODE :
$connection = mysql_connect("localhost","user","1234"); if(!$connection) { die('Failed to connect to MySQL :' . mysql_error()); } mysql_select_db("baybeestore",$connection) $sql = "INSERT INTO form(name, address, email, handphone, item, payment) VALUES ('$strname', '$straddress', '$stremail', '$strhandphone', '$stritem', '$strpayment')"; if(!mysql_query($sql, $connection)) { die('Error : ' . mysql_error()); } echo "Data have been saved."; mysql_close($connection);
As per your edit/added code. Your originally posted code
You're using two different tables for your queries. Result: ERROR
You have SELECT * FROM order
and INSERT INTO form
2 different animals altogether.
If anything, that should be INSERT INTO order
or SELECT * FROM form
yet... ORDER
is a reserved word and should be enclosed with backticks.
I.e.:
INSERT INTO `order`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With