Hey, a beginner’s question here….
In order to learn PHP and SQl I have set up a Localhost Server on my computer running Apache and phpmyadmin, using MAMP.
In the course of testing, I have found that through the backend phpmyadmin interface I can modify the db as I please without any trouble. However, when I try to query the db through php scripts, no changes seem to be committed.
I say this because it seems that I am able to open a connection to phpmyadmin, evident by the error messages I receive when trying to pass a malformed query.
When I run these scripts, and then check the backend, I see no changes even though I received no errors.
My best guess would be php is incorrect. So here is what I am using.
<?php
$connect = mysql_connect("localhost", "roo", "root");
if(!$connect){
die('COULD NOT CONNECT! HURS WHY : ' . mysql_error());
}
echo "Connection Success";
mysql_select_db("Geodb", $connect);
mysql_query("INSERT INTO countries (country_code, country_name)
VALUES ('uk', 'United Kingdom')");
mysql_close($connect);
?>
I suspect that this has been a problem because i am a beginner, but I have tried solving it and searched for an answer… So I hope you won’t mind helping me out haha.
Thanks
Chances are that an error is being thrown, but not displayed due to your
display_errorsphp.ini setting. As such, I’d recommend checking your error logs.Additionally, as this isn’t a production environment (and hence it’s OK to show errors) you’ll probably want to change your display_errors setting to on (
display_errors = On) and your error_reporting level to…or, better still…
…within your php.ini file.
By doing this, you’ll be informed of all the errors, warnings and notices that are occurring.