Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 尝试使用WAMPSERVER保存到数据库时出现MySQL连接问题_Php_Mysql_Database_Forms - Fatal编程技术网

Php 尝试使用WAMPSERVER保存到数据库时出现MySQL连接问题

Php 尝试使用WAMPSERVER保存到数据库时出现MySQL连接问题,php,mysql,database,forms,Php,Mysql,Database,Forms,我想把我的代码粘贴到wampserver上的数据库中,但当我尝试连接时,结果是糟糕的。是的,我尝试了3306作为主机,8080作为主机。页面无法加载 <?php $connect = mysql_connect("localhost:8080", "root", "mypassword"); echo($connect);?> 它说它是受限的,有什么我忘记做的吗?我需要下载windows mysql文件还是在mysql.ini中修改一些配置 这可能是不需要的,但这里的形式无论如何

我想把我的代码粘贴到wampserver上的数据库中,但当我尝试连接时,结果是糟糕的。是的,我尝试了3306作为主机,8080作为主机。页面无法加载

<?php
$connect = mysql_connect("localhost:8080", "root", "mypassword");
echo($connect);?>
它说它是受限的,有什么我忘记做的吗?我需要下载windows mysql文件还是在mysql.ini中修改一些配置

这可能是不需要的,但这里的形式无论如何

<div class = "submit">
<div class = "submit-container">
<h2 style = "font-size:25px;"><strong>Submit a Question.</strong><br></h2>
<img class = "divider2" src = "http://i.imgur.com/ynGf6UM.jpg" alt = "divide2">
<h4>
Have a question? <br> Post is here!
<br/>
</h4>
<br/>
<form name = "question" form action = "Question.php" method="get">
<input id = "poster" type="text" name="poster" required="required" placeholder = "Your   name.">     <br>
<textarea class = "actual-question" name = "actual-question" required="required" placeholder = "Write the question here!"></textarea><br><br><br>
<div class = "checkboxes" required="required">
<h3 style = "margin-top:-20px;">Please select one catagory that the question falls  into.</h3>
<label for="x"><input type="radio" name="x" value="Stupid" id = "x" checked="checked" /> <span>Stupid</span></label><br>
    <label for="x"><input type="radio" name="x" value="Stupider" id = "x" />    <span>Stupider</span></label><br>
    <label for="x"><input type="radio" name="x" value="Stupidest" id = "x" />    <span>Stupidest</span></label>
</div>
<input id = "submit1" type="submit"><br>
</form>
<div class = "contain-info">
        <p style = "float: left; font-size:14px;"><strong>Your name:  </strong> Write your own name here!</p><br>
        <p style = "float: left; font-size:14px;"><strong>Quote:</strong> Write the question you thought of here!</p>

</div>
</div>
</div>
这是另一个页面上的php,这是我保存到数据库中的内容

<div class="wrapper">
<div class="submissions">
    <div class="logo-logo"><h2>Question.</h2>
<div class="checkboxes"><?= !empty($_GET['x']) ? $_GET['x'] : '' ?>
</div>

    </div>

<div class="top-submit"><?php echo '&#8220;' . (!empty($_GET['actual-question']) ? $_GET['actual-question'] : '') . '&#8221;';?>
</div>
<div class="poster"><?php echo "-" .  (!empty($_GET['poster']) ? $_GET['poster'] :'');?>
<div class = "like">
<a href = "javascript:countClicksLike();" class = "btn btn-large" style = "color:green;">Like</a>
<p id = "like" style = "color:green;">0</p>
</div>
<div class = "dislike">
<a href = "javascript:countClicks();" class = "btn btn-large" style = "float:right; color:red;">Dislike</a>
<p id = "dis" style = "color:red;">0</p>
</div>
</div>
</div>
</div>
这可能是非常简单的,如果这是一个愚蠢的问题,我很抱歉,但我已经尝试了2个小时,似乎没有任何效果,当代码在其中时,带有php的页面甚至不会加载

谢谢你们的建议,伙计们,这很有帮助。 谢谢
-从PHP5.5.0开始,Connor已被弃用。相反,应该使用MySQLi或PDO_MySQL扩展。您得到的错误警告是什么。尝试使用空密码并保持localhost不变。当我在我的wampserver上进行测试时,它工作了

 <?php
 $connect = mysql_connect("localhost", "root", " ") or die("could not connect to the DB");
 echo("Connection successful");?>

您是否也尝试删除端口号?这有时会有帮助。弗雷德说的端口号是对的。当您运行Web服务器时,mysql根本不可能在8080上监听。您可以从服务器上的命令行连接到mysql吗?在一个只运行php试图连接mysql数据库的页面上会发生什么?谢谢你的回答,但现在它给了我这个答案。第14行是上面的php代码所在的位置!警告:mysql\u connect:C:\wamp\www\quest\quest\Question.php第14行调用堆栈时间内存函数位置1 0.0009 25326{main}.\Question.php:0 2 0.0009 254128 mysql\u connect.\Question.php:14实际上现在它工作了,我稍微修改了一下,现在错误消失了。现在接通了吗?