/    Sign up×
Community /Pin to ProfileBookmark

Why isn’t my assignment taking place?

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:-

[code=php]
<?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
}
}
?>
[/code]

Output in the Browser:

[code=html]
/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
[/code]

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.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ChaosengineauthorFeb 21.2008 — 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.
[code=php]
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>";
[/code]


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.
Copy linkTweet thisAlerts:
@ChaosengineauthorFeb 21.2008 — 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.
[code=php]
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>";
[/code]


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.[/QUOTE]


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

Initially I had used only:-

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

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:-

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

Hope this help someone. ?
×

Success!

Help @Chaosengine spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...