0

this following code:

//Add Template Documentation
$sql2 = "SELECT (doctype, templatename)FROM templates_documents WHERE templates_document.scope = '".$values["msscope"]."'";
$result = mysql_query($sql2);
$row = mysql_fetch_array($result);

$sql = "INSERT INTO documents_doucments (companyfk, doctype, doctitle) values('".$values["companypk"]."','$row[doctype]','$row[templatename]')";

Is giving me the following error:

mysql_fetch_array() expects parameter 1 to be resource, boolean given

user3169979
  • 47
  • 1
  • 7

2 Answers2

0

You have to specify what you expect for results

These are the parameters you can use: MYSQL_ASSOC, MYSQL_NUM and MYSQL_BOTH.

Like this

mysql_fetch_array($result, MYSQL_ASSOC);

Maby this helps you: http://php.net/manual/en/function.mysql-fetch-array.php

Rizier123
  • 57,440
  • 16
  • 89
  • 140
0

From the mysql_query PHP page, it says:

For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.

The fact that it is a boolean, means that it returned FALSE, and there is an error with your SQL statement.

Checking your SQL, I see you added parentheses around the fields. Try the following SQL:

$sql2 = "SELECT doctype, templatename FROM templates_documents WHERE scope = '".$values["msscope"]."'";
Wouter Thielen
  • 966
  • 8
  • 21