Hello everyone, this is my first post on these forums because i just joined. I am learning PHP and MYSQL and I have an issue with PHP since I want my code to do the following:
In a page called countries.php, I want it to display a table of information that it gets from a MYSQL table which has a list of countries (column name country_name) and their capitals (column name capital).
Either on the same page or on a different one add_new.php, I have a form to add a new country and its capital from the list. Right now I have these 2 PHP files (countries.php and add_new.php) but I get this error which I tried to fix:
Notice: Undefined variable: country in C:\wamp\www\countries.php on line 27
Notice: Undefined variable: capital in C:\wamp\www\countries.php on line 27
This is my code thus far:
countries.php
[php]
Country | Capital |
".$info['country_name'] . " | "; Print "".$info['capital'] . " |
add_new.php
[php]
Country:
Capital:
<?php // Connects to Database mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("countries") or die(mysql_error()); $data = mysql_query("SELECT * FROM general_info") or die(mysql_error()); $country = $_POST['country']; $capital = $_POST['capital']; $query = "INSERT INTO general_info (country_name, capital) VALUES ('$country', '$capital')"; ?> [/php]
Thank you.