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

独自空忆成欢 提交于 2019-12-25 03:00:11

问题


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>


回答1:


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

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


来源:https://stackoverflow.com/questions/33127983/local-host-setup-with-mamp-phpmyadmin-file-not-found-on-this-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!