0

I want to get the data from my database. The page does not change when I upload the file. Where am I wrong?

verifycheck.php

<?php
$con=mysql_connect ("###", "###", "###");
mysql_select_db ("db_name", $con);


$result = mysql_query($con,"SELECT * FROM db_tablename");


echo "<table border='1'>
<tr>
<th>username</th>
<th>email</th>
<th>password</th>
<th>confirm_password</th>
</tr>";

while($row = mysql_fetch_assoc($result)) {
  echo "<tr>";
  echo "<td>" . $row['username'] . "</td>";
  echo "<td>" . $row['email'] . "</td>";
  echo "<td>" . $row['password'] . "</td>";
  echo "<td>" . $row['confirm_password'] . "</td>";
  echo "</tr>";
}

echo "</table>";

mysql_close($con);
?>
6
  • What file do you upload? If your mysql parameters correct and has true column names in table and that table has some values, your code should work. Commented May 30, 2014 at 11:13
  • I believe that the problem is not in this code, since the OP mentions: The page does not change when I upload the file. Commented May 30, 2014 at 11:15
  • It's simple, the connection variable comes at the end and not at the beginning; unlike mysqli_ Commented May 30, 2014 at 11:15
  • 2
    @Fred-ii- I think that instead of changing the position of the parameter so it will fit mysql_ , he should leave the position of that parameter and start using mysqli_ :) Commented May 30, 2014 at 11:16
  • @OfirBaruch I couldn't agree with you more ;-) Commented May 30, 2014 at 11:16

3 Answers 3

1

Connection object should be second parameter and query string should be first parameter.

Try this

$result = mysql_query("SELECT * FROM db_tablename",$con);

Instead of

$result = mysql_query($con,"SELECT * FROM db_tablename");

Mysql function is deprecated and will remove in future go for Mysqli or PDO for preventing sql injection

Sign up to request clarification or add additional context in comments.

1 Comment

I tried it but the webpage is still not showing the data from the database.
0

Remove $con, from the mysql_query

As mysql_query() expects first parameter to be the SQL Query, not the SQL connection.

$result = mysql_query("SELECT * FROM db_tablename");

Comments

0

Please Check with your connection parameters as localhost,username password, database and also changing the

  $result = mysql_query($con,"SELECT * FROM db_tablename"); 
   as 
   $result = mysql_query("SELECT * FROM db_tablename",$con);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.