-1
Good afternoon, I’m trying to create a webservice but when I run it presents me these errors
i have 3 files in this webservice follows the code
php access.
<?php
$xml = simplexml_load_file("http://localhost/json/index.php");
print_r($xml);
?>
index php.
<?php
require_once('html-class.php');
$xml = new Xml();
$db = 'localhost:F:\Dados\TGA.FDB';
$username = 'SYSDBA';
$password = 'masterkey';
// Connect to database
$idmov = $_GET['id'];
$erro = 0;
$xml -> openTag("response");
$dbh = ibase_connect($db, $username, $password);
if($idmov == ''){
$erro = 1;
$msgerro = 'Codigo invalido!';
}
else{
$sql = 'SELECT * FROM TMOV WHERE IDMOV = $idmov';
$rc = ibase_query($dbh, $sql);
if(ibase_fetch_row($rc) > 0){
$reg = ibase_fetch_object($rc);
$xml-> addTag('IDMOV', $reg -> IDMOV);
$xml-> addTag('CODCFO', $reg -> CODCFO);
}
}
$xml -> addTag('erro', $erro);
$xml -> addTag('msgerro', $msgerro);
$xml -> closetag("response");
echo $xml;
?>
html-class.php
<?php
/**
*
*/
class Xml{
private $xml;
private $tab = 1;
public function_construct($version = '1', $encode = 'UTF-8'){
$this ->xml .= "<?xml version = '$version' encoding = '$encode' ?> \n";
}
public function openTag($name){
$this -> addTab();
$this -> xml .= "<$name>\n";
$this ->tab++;
}
public function closeTag($name){
$this ->tab--;
$this -> addTab();
$this ->xml .= "</$name>\n";
}
public function setValue($value){
$this -> xml .= "$value\n"
}
private function addTab(){
for ($i = 1; $i <= $this ->tab; $i++){
$this -> xml .= "\t";
}
}
public function addTag($name, $value){
$this -> addTab();
$this ->xml .= "<$name>$value</$name>\n";
}
public function _toString(){
return $this ->xml;
}
}
?>
So I’ve already searched for comma error, everyone I found I fixed, and now I’m lost in what may be
after I fix this error now it returns this Notice: Undefined index: id in C: xampp htdocs json index.php on line 13 Recoverable fatal error: Object of class Xml could not be converted to string in C: xampp htdocs json index.php on line 35
– Matheus Martins
@Matheusmartins just read the error and see which line, it is missing to define the id in the url of index.php to catch, but I have no way to guess the origin of the ID, what I can say is that you have to do something like this:
$xml = simplexml_load_file("http://localhost/json/index.php?id=VALOR_DO_ID");
, but where you will get I have no way of knowing, because your access.php only has two lines– Guilherme Nascimento
Thank you very much, sorry for the half ignorant question that I’m new, but you’ve helped me enough.
– Matheus Martins
For nothing @Matheusmartins, what matters is to describe also the goal in the question, because sometimes just looking at the error can not help totally, if you tell how it should work helps you help him ;)
– Guilherme Nascimento