Jump to content

Recommended Posts

after submitting my dropdown box form i get Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\www\homepage\google.php on line 146

 

the php form im getting $_POST from (the dropdown box):

 

<form id="loginForm" name="drop" method="post" action="google.php">
<?php
      mysql_connect('localhost','root','');
      if (!isset($_POST['email'])) {
        $q = mysql_query("SELECT * FROM members");
        echo "<select name='email'>";
        while ($row = mysql_fetch_assoc($q)) {
          echo "<option value='{$row['email']}'>{$row['firstname']}</option>";
        }
        echo "</select>";
      }else {
        print_r($_SERVER);
        print_r($_POST);
      }
    ?>
<input type="submit" name="submit" value="Submit Now" />

 

and here is the php file which is giving my the error:

<?php
      mysql_connect('localhost','root','');
      if (!isset($_POST['email'])) {
        $q = mysql_query("SELECT * FROM members");
        echo "<select name='email'>";
        while ($row = mysql_fetch_assoc($q)) {
          echo "<option value='{$row['email']}'>{$row['firstname']}</option>";
        }
        echo "</select>";
      }else {
        $row = mysql_fetch_assoc(mysql_query("SELECT * FROM members WHERE firstname = '{$_POST['email']}'"));
    
        print_r($row);
      }
    ?>

 

like 146 is

$row = mysql_fetch_assoc(mysql_query("SELECT * FROM members WHERE firstname = '{$_POST['email']}'"));

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/183063-mysql_fetch_assoc-error-help-please/
Share on other sites

<?php
      mysql_connect('localhost','root','');
      mysql_select_db("clients");

      if (!isset($_POST['email'])) {
        $q = mysql_query("SELECT * FROM members");
        echo "<select name='email'>";
        while ($row = mysql_fetch_assoc($q)) {
          echo "<option value='{$row['email']}'>{$row['firstname']}</option>";
        }
        echo "</select>";
      }else {
        $row = mysql_fetch_assoc(mysql_query("SELECT * FROM members WHERE firstname = '{$_POST['email']}'"));
    
        print_r($row);
      }
    ?>

 

Should do it.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.