Вопрос

I am wanting to stick my code in a database on a wampserver, but when I try to connect, it turds out (yes I have tried doing 3306 as the host aswell as 8080) the page just doesn't load.

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

It says its restricted, is there something I am forgetting to do? Do I need to download the windows mysql file or mess with some configuration within the mysql.ini?

This probobly isn't needed but here's the form anyway.

<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>

and here's the php on a different page, this is what i am saving to the database

<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>

This is probobly bone dry simple, i'm sorry if this is a stupid question, but i've been trying for 2 hours and nothing seems to work, the page with the php won't even load when the code is in it.

Thanks for any suggestions guys, it helps buckets. Thanks, -Connor

Это было полезно?

Решение

mysql_connect has been deprecated as of PHP 5.5.0. instead, the MySQLi or PDO_MySQL extension should be used. What is the error - warning you get. Try using empty password and leave localhost as it is. It worked when I did the test on my wampserver.

 <?php
 $connect = mysql_connect("localhost", "root", " ") or die("could not connect to the DB");
 echo("Connection successful");?>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top