Local host setup with MAMP & phpMyAdmin. File not

2019-09-13 23:21发布

How do i get my local .php file to show up, so i see my form. When i write local host and then path of .php file i get "Not Found" page.

If i add :8889 to local host it seems to run via MySQL-port(8889) instead of Apache-port(8888) and then safari just downloads the file to my downloads.

Here i have attached an images that shows all my settings.

I use MAMP, phpMyAdmin and i follow the guide of this guy (https://youtu.be/wp6Ngpk5XiY?list=PL530D33D6E548481F (17.05=troubleshooting))

Here is the code he use (i have copied his source code)

The communication to MySQL:

    <?php

define('DB_NAME', 'demo');
define('DB_USER', 'root');
define('DB_PASSWORD', 'root');
define('DB_HOST', 'localhost');

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

if (!$link) {
    die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db(DB_NAME, $link);

if (!$db_selected) {
    die('Can\'t use ' . DB_NAME . ': ' . mysql_error());
}

$value = $_POST['input1'];
$value2 = $_POST['input2'];

$sql = "INSERT INTO demo (input1, input2) VALUES ('$value', '$value2')";

if (!mysql_query($sql)) {
    die('Error: ' . mysql_error());
}

mysql_close();
?>

The form:

<form action="demo.php" method="post" />
<p>Input 1: <input type="text" name="input1" /></p>
<p>Input 2: <input type="text" name="input2" /></p>
<input type="submit" value="Submit" />
</form>

enter image description here

1条回答
The star\"
2楼-- · 2019-09-13 23:48

Follow this guys instructions and write localhost:8888/demo-form.php

Problems with MAMP on Yosemite 10.10 i use 10.10.5 i also worked for me

Set MAMP and Dreamweaver to htdocs and not another default directory

  • And change your php file to link to the datebase forms1 and not the database table demo.
查看更多
登录 后发表回答