Forum Moderators: open

Message Too Old, No Replies

Help with insert (i'm a newbie so take it slow)

programmer is unreachable and client needs this solved

         

Sari

6:25 pm on Apr 11, 2006 (gmt 0)

10+ Year Member



I hired a programmer to create an online survey for a client. Sounds simple right? lol that's what i thought too! ;) I've run into issues and I have been unable to reach the programmer and of course the client wants things fixed asap.

Anyway, the survey has been up for about a week (after 4 days of testing) and the client is just now reporting issues.

I'm trying to test without skewing the survey results so I created a duplicate database, and duplicated the files and pointed to the duplicate database for testing.

Now when I try to submit the test version of the survey, I get the following error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/user/public_html/subdomain/web_servicestest.php on line 91

Here's lines 85-110 of that file:


function wsInsertAnswers($department_id, $level_id, $answer_array)
{
$survey_id = wsGenerateGUID();
$sql = "INSERT INTO surveys (survey_id, department_id, level_id)
SELECT '" . $survey_id . "', '" . $department_id . "', '" . $level_id . "'";
if (mysql_query($sql))
{
// insert survey details
for ($i = 0; $i < count($answer_array); $i++)
{
$survey_detail_id = wsGenerateGUID();
$sql = "INSERT INTO survey_details (survey_detail_id, survey_id, question_id, " . $answer_array[$i][1] . ")
VALUES ('" . $survey_detail_id . "', '" . $survey_id . "', " . $answer_array[$i][0] . ", " . $answer_array[$i][2] . " )";
if (!mysql_query($sql))
{
wsRollbackInsertAnswers($survey_id);
return false;
}
}
return true;
}
else
{
return false;
}
}

Can anyone tell me how to correct this error?

Thanks in advance!

Sari

syber

12:09 pm on Apr 12, 2006 (gmt 0)

10+ Year Member



Don't you need a FROM clause for the SELECT statement on line 90? Otherwise, it has no way of knowing what $survey_id is.

Sari

12:51 pm on Apr 12, 2006 (gmt 0)

10+ Year Member



thank you syber for your reply.

I was finally able to get a hold of the programmer, several hours later, and he has now fixed the issue. :)

I'm not sure what the fix was (I was too tired to ask by the time it was finished).

Thanks again!
Sari