0

I am attempting to retrieve some data from my database, I appear to be able to connect to the database as I do not get an error message after the connection is tested. But when I attempt to run a select query, it causes an internal error.

If I take the FROM part away from the query, the page loads with no data. If I add the FROM part back in, with the table to be selected from, the internal error occurs.

The code is below:

$con = mysqli_connect("50.62.209.87:3306","myusername","mypassword",
"FiveExtras");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

     $query = "SELECT `EventVenue`,`EventDate`,`EventTime`,
     `EventPostCode` FROM `event`";

  $result = mysqli_query($con, $query);


$row = $result;

echo $row;
halfer
  • 19,824
  • 17
  • 99
  • 186
user3519506
  • 135
  • 1
  • 2
  • 11

2 Answers2

1

did you change your htacess? Changes to .htacess often cause internal server error. or your host ip is bad(try no-ip.com, they give free subdomains for your ip's)


i checked it with removed port it worked(well...not connecting but no error about host), so maybe it's something to do with port


if error 500 remains try get support ticket or email webmaster or get another hosting provider


why would you say no error?

here we go:

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given
in /home/u451361813/public_html/test.php on line 13

and

Warning: mysqli_connect(): (28000/1045): Access denied for user
'myusername'@'185.28.20.221' (using password: YES) in /home/u451361813
/public_html/test.php on line 3
Failed to connect to MySQL: Access denied for user 
'myusername'@'185.28.20.221' (using password: YES)

1st one is for no information returned second for no password

Deimantas
  • 56
  • 1
  • 14
1

Rewrite your connection:

$db_conn = mysqli_connect("$host", "$dbuser", "$dbpass") or die("Unable to connect to the database");
mysql_select_db("$dbase", $db_conn) or die("Unable to select the database");

$query = mysqli_query("SELECT `EventVenue`,`EventDate`,`EventTime`,
 `EventPostCode` FROM `event`");

And why $result = $row ?

EDIT: For a better query , use "SELECT * ... "

Makyen
  • 31,849
  • 12
  • 86
  • 121
GasKa
  • 54
  • 6