Help with passing XML variables to MySQL DB via PHP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with passing XML variables to MySQL DB via PHP
# 1  
Old 12-16-2010
Help with passing XML variables to MySQL DB via PHP

Hi everybody, I need the help of the Unix community once again Smilie

I have some code which queries an XML feed and displays the results for me. I would like to enter the XML output in to my database, but I am having trouble passing the variables while INSERTing.
Here is my code that I need to alter:
PHP Code:
<?php

    define
('SORT''/**searchterm**?format=georss');
    
define('QUERY_0''http://***********/search/si/');

function 
getSEARCH() {

    
$number "1";
    
$word urlencode($_POST['word']);
    
    
$alphaNUM "$number/$word";
    
$url0 QUERY_0.$alphaNUM.SORT;
    
$ch0 curl_init();
    
curl_setopt($ch0CURLOPT_URL$url0);
    
curl_setopt($ch0CURLOPT_HEADER0);
    
curl_setopt($ch0CURLOPT_RETURNTRANSFERTRUE);
    
curl_setopt($ch0CURLOPT_FAILONERRORTRUE);
    
$output curl_exec($ch0);
    
curl_close($ch0);
    
$xml preg_replace("/(<\/?)(\w+):([^>]*>)/""$1$2$3"$output);
    
$xml = new SimplexmlElement($xml);

    
$word urldecode($word);
    echo 
"<h3>You searched for: $word</h3>";
    
foreach (
$xml->channel->item as $data
   {echo 
'<div style="background-color:#ffff99;width:100%;padding:2px;border: 1px solid rgb(0, 0, 0); overflow: auto;">';
    echo 
"<h3>";
    echo 
$data->title "<br />\n";
    echo 
"</h3>";
    echo 
$data->description "<br />\n";
    echo 
$data->georsspoint "<br />\n";
    echo 
"<p>\n";
    echo 
'</div>';}}

getSEARCH();

?>
Any help would be greatly appreciated and thanks for taking the time to read this thread Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing awk variables to bash variables

Trying to do so echo "111:222:333" |awk -F: '{system("export TESTO=" $2)}'But it doesn't work (2 Replies)
Discussion started by: urello
2 Replies

2. Shell Programming and Scripting

Large XML to MySQL - fast way

Hello, Sorry for my bad english. I need to improve performance in project managing large data, these data are exported to a MySql from XML. Now I use PHP (XMLReader ()) to do this job. I need a faster way to do this process. Which do you think is the best way? Example: (the item... (2 Replies)
Discussion started by: stendelis
2 Replies

3. Shell Programming and Scripting

passing an unix variable to an XML

I need help I have a unix command : VERSION=$(ls -d /vsn/v12.??.??.?? | sort | tail -1) when i do echo $VERSION, i get the exact value, i want. Now i want to use this variable and pass it to an xml. How can i do that? (1 Reply)
Discussion started by: samk
1 Replies

4. Shell Programming and Scripting

Passing variables from bash to php-cli

Hello everyone, I've been looking how to pass variables between bash and php-cli in 1 file. So far i got this: #!/bin/bash echo "This is bash" php << EOF <?php echo "This is php\n"; ?> EOF I would now like to be able to pass a variable declared in the bash to the php. I already... (0 Replies)
Discussion started by: robbee
0 Replies

5. Shell Programming and Scripting

Passing 2 variables

Hi All, I need to pass 2 variables name 'vamskt' and 'vamsi'. Here is my question: delete from gpi.usergroup where usg_user_id in ('vamskt'); delete from gpi.userroles where uro_user_id in ('vamskt'); delete from gpi.user where usr_id in ('vamskt'); insert into gpi.user... (3 Replies)
Discussion started by: tvamsikiran
3 Replies

6. Shell Programming and Scripting

Passing a MySql password from bash script

Hi all, I am running this script on Mandrakelinux release 10.1, 2.6.8.1-12mdksmp #1 SMP I have also installed 'expect' separately. I have created an Rsync script, but before any Rsync command does run, a MySql dump must be done first, and I am battling a bit to pass the MySql password from... (2 Replies)
Discussion started by: codenjanod
2 Replies

7. Shell Programming and Scripting

Passing a variable from shell script to mysql query?

I heard this was possible but from my research I haven't been able to figure it out yet. Seems it should be simple enough. Basically from a high level view I'm trying to accomplish... . $X='grep foo blah.log' then 'mysql command SELECT foo FROM bar WHERE ' . $X or something like that. ... (2 Replies)
Discussion started by: kero
2 Replies

8. UNIX and Linux Applications

passing regular expressions to mysql via $1

hi, unix and mysql gurus. i'm trying to create a simple ksh script that accesses the mysql system database table, user. the idea is that the user can call the script with a regular expression to see some users, or call it without any options to see all users. this is what i have so far: ... (4 Replies)
Discussion started by: ankimo
4 Replies

9. Shell Programming and Scripting

passing variables

Hi, Is there any way to pass variable to a sed script.For awk we have -v option.like that do we have any way to pass variable to a sed script from a awk script or from normal script? Thanx, sounder (1 Reply)
Discussion started by: sounder123
1 Replies
Login or Register to Ask a Question