Saturday 15 August 2015

PHP/mySQL get_file_contents and update the column -



PHP/mySQL get_file_contents and update the column -

i have mysql db table. 1 of table columns contains urls point different xml files on remote server.

my goal read each urls info , write xml content column on same record (line) respectively.

in php code, able url correctly mysql database , able xml content on remote server variable correctly.

but issue while write content table line line. xml columns got update correctly , xml columns empty.

i pretty sure each time variable got content correctly because able print out each individual content on screen.

why content updating column , don't. xml strings have same format. if copied content , updated mysql table manually, wrote table.

at origin thought time issue add together plenty sleep time php code. does't help. suspected db datatype, changed xml column info type vchar text , longtext. does't help either. 1 have clue?

part of php code below...

$result = mysqli_query($con,"select url_txt mytable "); //work result line line: while($row = mysqli_fetch_array($result)) { echo $url_content = file_get_contents($row['url_txt']); //debug line below *******************************/ echo $url=$row[url_txt]; //debug line above********************************/ mysqli_query($con,"update mytable set xml_info='$url_content' url_txt = '$url' "); }

maybe seek converting xml native array , working way:

$array = json_decode(json_encode(simplexml_load_string($url_content)),true);

php mysql

No comments:

Post a Comment