hi there
I'm really stuck and would appreciate any help,
I'm trying to get PHP to write a relative directory url path to my images into the XML, instead of what its writing now, which is a absolute path.
like so:
<imageurl>/var/www/vhosts/oconnellconstruction/images/image.jpg</imageurl>
This the code i'm using
<?php
// filename: upload.success.php
$DBhost = "localhost"; // Database Server
$DBuser = "DBuser"; // Database User
$DBpass = "DBpass"; // Database Pass
$DBName = "DBName"; // Database Name
$table = "Images "; // Database Table
// Connect to mySQL Server
$DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error in Images Application: " . mysql_error());
// Select mySQL Database
mysql_select_db($DBName, $DBConn) or die("Error in Images Application: " . mysql_error());
$query = "SELECT * FROM $table";
$dbresult = mysql_query($query, $DBConn);
echo "Connected";
function Display($Value) {
return htmlspecialchars(addslashes($Value));
}
$xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n\n";
$xml .= "<gallery>\n\n";
while ($dat = mysql_fetch_array($dbresult)) {
$xml .= "\t<imageurl>".Display($dat['pic'])."</imageurl>\t\n";
}
$xml .= '</gallery>';
$Fichier = fopen('gallery.xml', 'w+');
fputs($Fichier, $xml);
fclose($Fichier);
?>
Is there someway i could alter this
while ($dat = mysql_fetch_array($dbresult)) {
$xml .= "\t<imageurl>".Display($dat['pic'])."</imageurl>\t\n";
so the relative url is printed and the fieldname from the database attached,
Sort of like this
while ($dat = images/($dbresult)) {
$xml .= "\t<imageurl>".Display($dat['pic'])."</imageurl>\t\n";
or
while ($dat = ($dbresult)) {
$xml .= "\t<imageurl>".Display(images/$dat['pic'])."</imageurl>\t\n";