0

For some reason I am getting an error this error:

mysql_fetch_array() expects parameter 1 to be resource, array

Here's the relevant code - I am trying to to take all of the values from an array ($culture), and insert each into a MySQL query individually.

if (isset($_POST["orgid"])  && ($_POST['orgid'] !== '')) {
$orgid = $_POST['orgid'];
    $query = mysql_query("UPDATE organization SET org_name='".$orgname."', add_1='".$add1."', add_2='".$add2."', city='".$city."', state='".$state."', zip='".$zip."', url='".$url."', email='".$email."', phone='".$phone."', contact='".$contact."', hours='".$hours."', notes='".$notes."', description='".$description."' WHERE org_id='".$orgid."'");   

while ($cultrow = mysql_fetch_array($culture)) {
    $query = mysql_query("update org_cult_xref set org_id='".$orgid."', cult_id='".$cultrow."'");    
}
}

Here's the form info:

<select name="culture[]" multiple="multiple"><?php
    while ($cultrow = mysql_fetch_array($rescult)) {
        ECHO '<option name="culture[]" value="'. stripslashes($cultrow['cult_id']) .'">'. stripslashes($cultrow['cult_desc']) .'</option>';
    }
    ?>
        </select></fieldset>
3
  • where did you set $culture? Commented Nov 28, 2011 at 13:52
  • $culture is set from all the variables of a picklist. Let me show you. Commented Nov 28, 2011 at 13:53
  • 2
    mysql_fetch_array() is used for retrieving data from a query and not for populating an update statement. Commented Nov 28, 2011 at 13:54

2 Answers 2

2

if $culture is not some sort of resource returned from a mysql_query function, you should supply the $query to mysql_fetch_array function. Of course if you want to use the result from the first update query.

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

Comments

0

Perhaps you are looking for the foreach structure?

foreach($culture as $cultid) {
    $query = mysql_query("update org_cult_xref set org_id='".$orgid."', cult_id='".$cultid."'");    
}

2 Comments

Ah, this makes more sense - I am so used to getting arrays from MySQL! Sorry, still new to PHP. Also, I like your handle, used a similar one for years.
Hrm, this does not appear to update org_cult_xref. Neither does an "insert into" - why would this be?

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.