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

时间:2014-05-13 01:05:29

标签: php mysql database forms

我想把我的代码粘贴在wampserver上的数据库中,但是当我尝试连接时,它会消失(是的,我已经尝试将3306作为主机以及8080)页面只是不加载

<?php
$connect = mysql_connect("localhost:8080", "root", "mypassword");
echo($connect);?>

它说它有限制,有什么我忘了做的吗?我是否需要在mysql.ini中下载windows mysql文件或搞乱一些配置?

这个问题并不是必需的,但无论如何都是这样的形式。

<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的页面赢得了#t甚至在代码进入时加载。

感谢任何建议人,它有助于桶。 谢谢, -Connor

1 个答案:

答案 0 :(得分:0)

自PHP 5.5.0起,不推荐使用mysql_connect。相反,应该使用MySQLi或PDO_MySQL扩展。什么是错误 - 警告你得到。尝试使用空密码并保留localhost。当我在我的wampserver上进行测试时,它工作正常。

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