Click to See Complete Forum and Search --> : Why isn't my assignment taking place?


Chaosengine
02-20-2008, 10:17 PM
I have a very strange problem that got me stuck..hoping someone here can enlighten me what went wrong. Below is my code snippet and the output:-


<?php
require("header.php");
session_start();
require("db.php");

if (isset($_POST["submit"]))
{ $lib = "/".$_POST["SVGLibraries"];
echo $lib."<br><br>";

$predir = $svgdir.$lib;
echo $predir."<br/> Test 0 <br/>";
$predir = $predir.$lib;
echo $predir."<br/> Test 1 <br/>";
$filename = $predir.".svg";
echo $filename."<br/> Test 2 <br/>";
$svgfile = fopen($filename, 'w');

if( $svgfile == FALSE )
{
echo "File Error! Please report this to the website administrator";
}
else
{
// DO something
}
}
?>


Output in the Browser:

/IHM039frV2
http://qlap04/db/SVG/IHM039frV2 Test 0
http://qlap04/db/SVG/IHM039frV2 Test 1
http://qlap04/db/SVG/IHM039frV2 Test 2

Warning: fopen(http://qlap04/ciadb/SVG/IHM039frV2</option/IHM039frV2</option.svg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /usr/local/apache2/htdocs/ciadb/wgiv.php on line 22
File Error! Please report this to the website administrator


Why does my assigment to combine the variables only worked the first time? Where did the '/option' come from?

Thanks to anyone who can enlighten me on this.

Chaosengine
02-21-2008, 02:20 AM
Hi

Seems like no respond yet. Anyway, I belive the '/option' is most likely due to the fact that 'SVGLibraries' is a drop-down list, and the result it return is one of the options. I don't understand why it didn't get printed when I echo but is included during the file-open.

I also believe the '/option' is also preventing further variable strings from getting appended to the original string.

Below is the code for the drop-down list.

echo "<select name='SVGLibraries' onChange='checkLibrary(this.form,this.options[this.selectedIndex].value)'>";
echo "<option value='invalid'>-- Select a Library --</option> <br />";

while ($row = mysql_fetch_array($result))
{
echo "<option value=".$row['name']."</option>";
echo $row['name'];
}
echo "</select>";


I will be trying to play around with the code and hopefully will determine the root cause. I will also check this post from time to time in case someone knows what I am doing wrong.

Thanks in advance.

Chaosengine
02-21-2008, 02:47 AM
Hi

Seems like no respond yet. Anyway, I belive the '/option' is most likely due to the fact that 'SVGLibraries' is a drop-down list, and the result it return is one of the options. I don't understand why it didn't get printed when I echo but is included during the file-open.

I also believe the '/option' is also preventing further variable strings from getting appended to the original string.

Below is the code for the drop-down list.

echo "<select name='SVGLibraries' onChange='checkLibrary(this.form,this.options[this.selectedIndex].value)'>";
echo "<option value='invalid'>-- Select a Library --</option> <br />";

while ($row = mysql_fetch_array($result))
{
echo "<option value=".$row['name']."</option>";
echo $row['name'];
}
echo "</select>";


I will be trying to play around with the code and hopefully will determine the root cause. I will also check this post from time to time in case someone knows what I am doing wrong.

Thanks in advance.

Solved. The problem was the drop-down list population.

Initially I had used only:-

echo "<option value=".$row['name']."</option>";

The list got populated, but it was all blank. So I added the other echo statement and the list was visible. Unfortunately, that, although wasn't the actual cause, it was obviously not the correct way to do it.

The resolution I used is:-

echo "<option value=".$row['name'].">".$row['name']."</option>";

Hope this help someone. :)