简体   繁体   中英

Local host setup with MAMP & phpMyAdmin. File not found on this server

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>

在此处输入图片说明

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

将MAMP和Dreamweaver设置为htdocs而不是其他默认目录

  • And change your php file to link to the datebase forms1 and not the database table demo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM