423,504 Members | 1,125 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,504 IT Pros & Developers. It's quick & easy.

Undefined variable: con Call to a member function query() on a non-object

P: 1
pleas help me in resolving error in this part

Expand|Select|Wrap|Line Numbers
  1. <div class="output"> <?php $sql ="SELECT * FROM posts";
  2. global $conn;
  3. $result= $conn->query($sql);
  4. $result=mysql_query("SELECT * FROM posts WHERE name='$name' and msg='$msg' ");
  5. if(isset($_POST['name'])&&isset($_POST['msg']))
  6. {
  7.  
  8. $uname=($_POST['name']);
  9. $msg=($_POST['msg']);
  10. }
  11. if($result->num_rows>0) 
  12. while($row = $result->fetch_assoc()){
  13. echo "".$row["name"]." "."::" . $row["msg"]."--" .$row["date"]. "<br>";
  14. }
  15. else{
  16. echo "0 results";
  17. }
  18. $conn->close();
  19. ?> </div>
Aug 11 '18 #1
Share this Question
Share on Google+
1 Reply


zmbd
Expert Mod 5K+
P: 5,283
You simply MUST tell us
- What is the error you are receiving
- What you wanted it to do
- What it is doing
-!- What YOU have already tried to fix the problem

Please use the [CODE/] formatting tool to format your script when posting :)

We cannot compile the code for you to troubleshoot
While many of us will review code, it's not really reasonable to just dump the code without explanation and expect us to read your mind.
Aug 11 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.