5

I started with this questions:

Fixing PHP PEAR error

And I went with what was suggested, but that does not appear to work.

My code now looks like this:

require 'DB.php';
require 'C:\Users\Clayton\Desktop\formhelpers.php';

$db = DB::connect('mysql://root:password@localhost/test');
if (DB::isError($db)) { die("connection error: " . $db->getMessage( )); }
$db->setErrorHandling(PEAR_ERROR_DIE);

//create table for responses 
$q = $db->query(
"CREATE TABLE apiResponse(
 Name VARCHAR(20),
 Occupation VARCHAR(20)");

//select data to send
$db = DB::connect('mysql://root:password@localhost/test');
$q = $db->query('SELECT Name, Occupation FROM try2 ');
while ($row = $q->fetchRow())
{
    $Name = $row[0];
    $Occupation = $row[1];

   $q = $db->query(
   "INSERT INTO apiResponse (Name, Occupation) values ($Name, $Occupation)"
);

Where require 'C:\Users\Desktop\formhelpers.php'; is line 10.

I still get a similar error:

Warning: require(C:\Users\Desktop\formhelpers.php) [function.require]: failed to 
open stream: No such file or directory in C:\xampp\htdocs\myfiles\Testing API 
Script.php on line 10

Fatal error: require() [function.require]: Failed opening required 
'C:\Users\Clayton\Desktop\formhelpers.php' 
(include_path='.;C:\xampp\php\PEAR') in 
C:\xampp\htdocs\myfiles\Testing API Script.php on line 10

Because the directory did not solve the problem I'm thinking my previous questions about editing the PEAR file may be relevant.

My questions:

The file that needs to be corrected is the php.ini file in xamp? (I previously downloaded php straight from php.net)

I have both a php.ini for development and for production... which one do I edit?

The .ini file opens in notepad, I'm not sure this is the correct place to edit it. Confirmation?

Community
  • 1
  • 1
user1459268
  • 217
  • 1
  • 3
  • 9

1 Answers1

1
$q = $db->query(
"CREATE TABLE apiResponse(
 Name VARCHAR(20),
 Occupation VARCHAR(20)");

there is missing the last parenthesis.

$q = $db->query(
"CREATE TABLE apiResponse(
 Name VARCHAR(20),
 Occupation VARCHAR(20))");
jcho360
  • 3,724
  • 1
  • 15
  • 24
  • The final while block is also missing a trailing `}`. but that may have just been accidentally truncated in the copy+paste shuffle. – Eric H Jun 22 '12 at 15:31