Jump to content

Help with PHP and MySQL query


lbh2011

Recommended Posts

You need to change this to a while loop

($row = mysql_fetch_assoc($result)) ;{

 

 

It was in your original code, so I don't know at what point you changed it. (Also, remove the semicolon)

while ($row = mysql_fetch_assoc($result)) {

 

Lastly, I inadvertently left off the column names in the dynamic query, which flolam corrected. But, you can make this line

$where_parts[] = str_replace("search", "user", $name)." = '".mysql_real_escape_string(trim($_POST[$name]))."'";

 

much simpler by naming your input fields the same as your db fields. Doing that makes it much easier on you in the future when you have to make changes to your code. That line would look something like this

$where_parts[] = "{$name} = '".mysql_real_escape_string(trim($_POST[$name]))."'";

Link to comment
Share on other sites

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.