Hello everyone,
first of all, here is my username as it is recommended to share: epiz_25903923
Situation
I recently restarted to code in php for a website that I want to connect to a database. Everything was working perfectly on my local environment with WAMP Server.
I was able to create a database via the Infinityfree control panel, inputed some data inside, was able to connect this database to my php that I uploaded on my website hosted by Infinityfree. Everything was fine until I tried to INSERT data to my database.
I spent the last 3 days looking everywhere, but I canāt find the solution to my problem.
Database
Here is the structure of my database (I start with an easy one, also tried with id but this did not seem to matter here) :
CREATE TABLE test (name varchar(256) not null);
PHP code
<?php
$dbServername = "sql101.epizy.com";
$dbUsername = "epiz_xxxxxxx";
$dbPassword = "xxxxxxxxx";
$dbName = "epiz_xxxxxxx_test";
$conn = mysqli_connect($dbServername,$dbUsername,$dbPassword,$dbName);
$name="Bob";
$sql = "INSERT INTO test (name) VALUES ($name);";
$worked=mysqli_query($conn,$sql);
if (!$worked)
{
echo "Error : cannot add to database";
}
else
{
echo "no problem";
}
?>
Error message
I activated the Alter PHP config on the Control Panel, because it might help to debug in the future.
However, with this simple code I only get the "Error : cannot add to database"
message and in fact no row is added to my databaseā¦
This code and even the more complicated codes I prepared for my website do work on WAMP on my local environement, but this simple one does not work once on Infinityfree. However I can get data from the database ⦠I donāt get it
Thank you very much if you read all this and I pray for someone to help me find the answer, Iām so sad right now ^^