Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-02-2006, 05:56 PM   #1
Registered: Nov 2003
Location: Germany
Distribution: Linux Mint 18.1
Posts: 39

Rep: Reputation: 15
PHP script to retrieve records from MYSQL db and pass them to an external program

I'm trying to write a small shell script that access my database, retrieves some records and use them to edit the tags of my ogg files. I use exec to execute vobiscomment. If the title is not a variable, vorbiscomment renames the tag:



   $link = mysql_connect("localhost","root","");


   $query = "select * from Eliza order by Title_ID limit 5";
   $result = mysql_query($query) or die("Could not: $query");

   while ($row = mysql_fetch_array($result))


print $row["Title"];
print "\n";

echo exec ('vorbiscomment -w -t title=Symphony 01.ogg');
print "\n";
print "\n";


The result is as follows:

$ vorbiscomment -l 01.ogg
However, if I set the title to be the variable, it doesn't work:
echo exec ('vorbiscomment -w -t title=$row["Title"] 01.ogg');

$ vorbiscomment -l 01.ogg
Also, it doesn't work like this:
echo exec ('vorbiscomment -w -t title=$title 01.ogg');

$ vorbiscomment -l 01.ogg
Apparently, the problem is how to declare the variable.
Any suggestions?
Old 08-02-2006, 11:51 PM   #2
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,406

Rep: Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396
Well, in shell and Perl single quotes mean don't interpolate vars ie don't cvt vars to values. double quotes do allow interpolation. could be the same for php?
Old 08-03-2006, 02:35 AM   #3
Registered: Dec 2005
Posts: 44

Rep: Reputation: 15
try this:

echo exec ('vorbiscomment -w -t title='.$row["Title"].'01.ogg');


$code = exec ('vorbiscomment -w -t title='.$row["Title"].'01.ogg');
echo $code;

or if if still won't work, try this:

$com = 'vorbiscomment -w -t title='.$row["Title"].'01.ogg';
$code = exec($com);
echo $code;
Old 08-03-2006, 02:09 PM   #4
Registered: Nov 2003
Location: Germany
Distribution: Linux Mint 18.1
Posts: 39

Original Poster
Rep: Reputation: 15
Thank you for your suggestion. This solved the problem:


$vorbis="vorbiscomment -w -t composer='$composer' -t title='$composer - $title' 01.ogg";
echo exec ($vorbis);


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to pass a row to another PHP script bahadur Programming 5 12-24-2011 01:07 AM
LXer: Title: PHP/MySQL Classifieds Script AddAsset1.php Script Insertion LXer Syndicated Linux News 0 07-02-2006 06:21 PM
script (or other) to pass variables to C++ program ngwenyama Programming 9 01-20-2005 09:54 PM
Import records to MySQL Database from a shell script chrisk5527 Linux - General 12 03-24-2004 09:49 PM
PHP Script to retrieve queries from log file saravanan1979 Programming 1 03-17-2002 08:13 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:56 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration