1

So I just started building a basic site in preparation for my internship in the coming weeks, and I installed MAMP and everything was working fine. Set up my database and began designing the site, then for some reason I just got a blank white screen.

I tried refreshing, restarting the browser and restarting MAMP and continue to get the same blank page. At one point I got a message saying it could not connect to the database but I can't reproduce it at the moment. When I did localhost:8889 to access the MySQL port I received a download page with the following text:

J 5.5.34TW8Qp]bVˇ˜Äe|]<.Utj7oNt}mysql_native_password!ˇÑ#08S01Got packets out of order

(added a period after the <. because it wouldn't show the rest)

I am new to this so I am not really sure what to do from here. Please explain as if you are talking to someone with no knowledge on the subject, I took a couple of courses last semester but never got into hands-on stuff like this.

tshepang
  • 12,111
  • 21
  • 91
  • 136
  • You have to use a MySQL Client to connect to the database. A web browser will not work. – Raj More May 20 '14 at 18:46
  • possible duplicate of [apache mysql - "packets out of order" on 3306](http://stackoverflow.com/questions/10053613/apache-mysql-packets-out-of-order-on-3306) – Raj More May 20 '14 at 18:49
  • I read in the other article and Raj said that I need a MySQL client to access the database. I am using MAMP which hosts a MySQL Server, and phpMyAdmin is in the browser when I open the start page. Is this not suitable or should I be using something else? I am on a Mac btw. – ryanjwessel May 20 '14 at 23:18

1 Answers1

0

Try with this code.

<?php
$con = mysql_connect('database host', 'user name', 'password'); //Database host may be:127.0.0.1:3306
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('database name', $con);
$sql="set names 'utf8'";// for unicode support, must use after mysql_select_db() function.
mysql_query($sql);
mysql_query('SET CHARACTER SET utf8')or die('charset problem:'.mysql_error());
mysql_query("SET SESSION collation_connection ='utf8_general_ci'") or die('collation      problem:'.mysql_error());

?> Thanks.

Muhammad Ashikuzzaman
  • 3,075
  • 6
  • 29
  • 53
  • name this code as dbcon.php. Suppose that you want to connect and do some task with database in user_ashik.php . Then include this php file in user_ashik.php with include("dbcon.php"); One question are developing sites with wordpress? @rynjwssl – Muhammad Ashikuzzaman May 21 '14 at 06:00
  • Yes I am developing the sites in Wordpress, thanks for the help Muhammad I will try this and get back to you on that – ryanjwessel May 22 '14 at 14:46