I am needing help. I want to create files with variable file names - I am creating a membership website and want each member to be able to have a blog username.htm The problem is that when I try to create this using the fopen function it is not recognizing the variable. This is the code I had:

$r=mysql_query("SELECT * FROM members WHERE Username='$_SESSION[username]'");
while($userinfo=mysql_fetch_array($r))
$blog=$userinfo[Username];
$cblog="$blog.htm";
$createblog=fopen($cblog,a);

Please can someone help. Thanks.

I think you are going about this the wrong way. Why not take advantage of what php has to offer to simplify everthing. You can have one php page generate a different blog for each member without having to create seperate static html pages.

I think you are going about this the wrong way. Why not take advantage of what php has to offer to simplify everthing. You can have one php page generate a different blog for each member without having to create seperate static html pages.

I had thought of doing it this way initially but then I thought that perhaps it would be better for my members SEO if each one had a static blog. Would a static page not achieve better SEO results than a dynamic one?

I am needing help. I want to create files with variable file names - I am creating a membership website and want each member to be able to have a blog username.htm The problem is that when I try to create this using the fopen function it is not recognizing the variable. This is the code I had:

$r=mysql_query("SELECT * FROM members WHERE Username='$_SESSION[username]'");
while($userinfo=mysql_fetch_array($r))
$blog=$userinfo[Username];
$cblog="$blog.htm";
$createblog=fopen($cblog,a);

Please can someone help. Thanks.

if that is your code it doesn't work because you forgot two apostrophe in username.

$_SESSION
$userinfo

You can get the seo you are looking for by using mod_rewrite.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.