I'm not a programmer, but I do understand a little bit of PHP. My problem is that I'm taking two program snippets that work well, but when I try to pass variables from the first one to the second, something breaks and nothing comes out.
The first part of the program selects a random record from a MYSQL database.
// Create the connection and select the DB
$link = mysql_connect("localhost","root","");
if ($link) {
mysql_selectdb("test",$link);
// Select records from the DB
$query = "SELECT * FROM names ORDER BY Rand() LIMIT 1";
$result = mysql_query($query);
// Display records from the table
echo "<table border='1'>";
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
The second part of the program uses XML RPC to post remotely to a WordPress blog.
$wp = new eWordpressApi("http://www.mysite.com/xml...
$title = "Testing";
$text = "Lorem Ipsum";
$category = array(Pants,Stuff); // Assuming you have categories with IDs: 1,2
$postID = $wp->newPost($title,$text,$category);
if(is_array($postID)) echo "Die, d**n bug!";
I've been trying to pass the results from mysql_fetch_array to the second program so that $title = row[0] and $text = row[1], row[2], but when I execute the script all it does it print the second program as text instead of passing the variable and executing the program.
I've been beating my head against the wall for a week on this problem. What am I doing wrong.
The complete program:
<?php
// Create the connection and select the DB
$link = mysql_connect("localhost","root","");
if ($link) {
mysql_selectdb("test",$link);
// Select records from the DB
$query = "SELECT * FROM names ORDER BY Rand() LIMIT 1";
$result = mysql_query($query);
// Display records from the table
echo "<table border='1'>";
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
$wp = new eWordpressApi("http://www.mysite.com/xml...
$title = "Testing";
$text = "Lorem Ipsum";
$category = array(Pants,Stuff); // Assuming you have categories with IDs: 1,2
$postID = $wp->newPost($title,$text,$category);
if(is_array($postID)) echo "Die, d**n bug!";
}
?>
Tags: