1

I am using WAMP for my PHP framework. I am trying to test this code

<?php
require_once "C:\wamp\www\factual-php-driver-master\Factual.php";
$factual= new Factual("/*API Key*/","/*API Secret*/");

$query= new FactualQuery;
$query->limit(3);
$res= $factual->fetch("places", $query);
print_r($res->getData());
?>

The PATH to my Factual.php file is absolutely correct but the file returns the following errors

Warning: require_once(C:\wamp\wwwactual-php-driver-master\Factual.php): failed to open stream: Invalid argument in C:\wamp\www\foodmeets\restaurants.php on line 2

Fatal error: require_once(): Failed opening required 'C:\wamp\wwwactual-php-driver-master\Factual.php' (include_path='.;C:\php\pear') in C:\wamp\www\foodmeets\restaurants.php on line 2

Please note I had performed the testing of the PHP install environment using the command

php -f test.php yourFactualKey yourFactualSecret [logfile]

as mentioned in the Factual Driver(V3) for PHP on Github(https://github.com/Factual/factual-php-driver)

Surya Sekhar Mondal
  • 179
  • 1
  • 1
  • 13

2 Answers2

1

you have to escape \f (The \f metacharacter is used to find a form feed character.)

require_once "C:\wamp\www\\factual-php-driver-master\Factual.php";
chandresh_cool
  • 11,753
  • 3
  • 30
  • 45
  • yes it is working now, but can you explain why this happened ? – Surya Sekhar Mondal May 31 '16 at 09:02
  • actually C:\wamp\www\factual-php-driver-master\Factual.php, in this \factual-php-driver-master had \f which is metacharacter used to find a form feed character. In php we need to escape all such things by using extra backslash hence \\factual-php-driver-master. – chandresh_cool May 31 '16 at 09:04
0

Your backslashes is converted into special chars by PHP. For instance, ...arrays\news.php gets turned into

...arrays

ews.php

You should escape them like this:

$path = "C:\NucServ\www\vv\static\arrays\news.php"; Or use singles, like this:

$path = 'C:\NucServ\www\vv\static\arrays\news.php';

Also, your if is messed up. You shouldn't fopen the file again. Just use your $fp which you already have.

Source failed to open stream: Invalid argument

Community
  • 1
  • 1
Ashish Chaturvedi
  • 1,352
  • 3
  • 13
  • 37