Re: Beginner help with mysql
> $con=mysqli_connect($host, $user, $pass);
Missing 4th parameter for database name.
> if (mysqli_connect_errno()) {
> echo 'Could not connect to mysql';
Uninformative. Better: exit( mysqli_connect_error() );
> $result=mysqli_query($con,$sql);
Needs error handling, minimally:
$result=mysqli_query($con,$sql) or exit( mysqli_error($con) );
> $row=mysqli_fetch_assoc($result);
If more than one row may be returned, you need a loop here to fetch them.
> printf ("%s (%s)\n",$row["iso_country"],$row["municipality"]);
Here too.
> Echo $row;
If you wish to echo the entire array ...
echo "<pre>";
print_r( $row );
echo "</pre>";
> trying to search my table C245051_small_airport to find fields associated with iso_country and municipality.
That query would be something like
select ... desired column names ...
from C245051_small_airport
where iso_country = 'some country code' and municipality = 'some town';
Subject
Written By
Posted
Re: Beginner help with mysql
October 05, 2015 11:00AM
November 03, 2015 02:51PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.