Jump to content

Archived

This topic is now archived and is closed to further replies.

RTS

profile about section

Recommended Posts

can some one tell me what might be wrong with this script? I am trying to  make it so the text in about in my database will show up in the table. My DB name is test, and my table name is users. I get [code]Parse error: parse error in /Library/WebServer/Documents/userlog.php on line 11[/code] when I open it
heres the code:
[code=php:0]<html>
<body>
<title>Profile</title>
<body bgcolor=336699>
<div align=center>
<table width=332 cellpadding=0 cellspacing=3>
<tr>
<td background=tableo.jpg
style=border-top:3px red solid;border-bottom:3px red
solid;border-right:36px red solid;border-left:3px red solid;>
?>
<?php  $con = mysql_connect(localhost,ZackBabtkis,);
if (!$con)
  {
  die(Could not connect:  . mysql_error());
  }
$user = echo $_COOKIE[user];
mysql_select_db(test, $con);

$result = mysql_query(SELECT about FROM users WHERE $user = user);

while($row = mysql_fetch_array($result))
  {
  echo $row[about];
  }
echo </table>;

mysql_close($con);
</td>
</tr>
</table>
</body>
</html>[/code]

Share this post


Link to post
Share on other sites
You have an ending php tag (?>) which doesnt seem to have an opeing PHP tag. Remove ?> from line 11.

Share this post


Link to post
Share on other sites
okay, but I still get the same error on line 11

Share this post


Link to post
Share on other sites
OKay. Looking at your your code, you are using strings but you aint put the quotes around them. When you use a string you need to place a quotes around it. Try this:
[code]<html>
<body>
<title>Profile</title>
<body bgcolor=336699>
<div align=center>
<table width=332 cellpadding=0 cellspacing=3>
<tr>
<td background=tableo.jpg
style=border-top:3px red solid;border-bottom:3px red
solid;border-right:36px red solid;border-left:3px red solid;>
<?php

$con = mysql_connect('localhost', 'ZackBabtkis', 'pass') or die('Could not connect:'  . mysql_error());

$user = $_COOKIE['user'];

mysql_select_db('test', $con);

$result = mysql_query('SELECT about FROM users WHERE $user = user');

while($row = mysql_fetch_array($result))
{
    echo $row['about'];
}

echo '</table>';

mysql_close($con);
?>
</td>
</tr>
</table>
</body>
</html>[/code]

Share this post


Link to post
Share on other sites
okay, that kind of worked. it gave me the background and the table with [code]
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /Library/WebServer/Documents/userlog.php on line 14[/code] in the middle. I think I know  nthe probnlem though. is it because I dont have the cookie sent saying what $user equals? I need to have that script from before written in my registreation page, so when you register, it creates that page. heres my code so far.
[code=php:0]<?php
$con = mysql_connect("localhost","ZackBabtkis","");
$password = md5($_POST['password']);
$username = mysql_real_escape_string($_POST[username]) or die("no");
$about = mysql_real_escape_string($_POST[about]);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
$write = ('<html>
<body>
<title>$username s Profile</title>
<body bgcolor=336699>
<div align=center>
<table width=332 cellpadding=0 cellspacing=3>
<tr>
<td background=tableo.jpg
style=border-top:3px red solid;border-bottom:3px red
solid;border-right:36px red solid;border-left:3px red solid;>
?>
<?php  $con = mysql_connect(localhost,ZackBabtkis,);
if (!$con)
  {
  die(Could not connect:  . mysql_error());
  }
$user = echo $_COOKIE[user];
mysql_select_db(test, $con);

$result = mysql_query(SELECT about FROM users WHERE $user = user);

while($row = mysql_fetch_array($result))
  {
  echo $row[about];
  }
echo </table>;

mysql_close($con);
?>
</td>
</tr>
</table>
</body>
</html><?php
');
$filename = "/Library/WebServer/Documents/users/$username.php";
$filehandle = fopen($filename, 'w') or die("can't create or open file");
fwrite($filehandle, $write);
fclose($filehandle);


mysql_select_db("test", $con);

$sql="INSERT INTO users
(username,password,first,last,email,phone,street,city,zip,state,country,month,day,year)
VALUES
('$_POST[username]','$password','$_POST[first]','$_POST[last]','$_POST[email]','$_POST[phone]','$_POST[street]','$_POST[city]','$_POST[zip]','$_POST[state]','$_POST[country]','$_POST[month]','$_POST[day]','$_POST[year]' )";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo '<html><title>Registered</title>
<body bgcolor="336699">
<div align="center">
<a href="home.html">
<embed src="YaddaYay_Banner.jpg">
</a>
<embed src="join.jpg" width="728" hight="30" usemap="#barmap">
<map id="barmap" name="barmap">
<area shape="rect"
coords="0,30,59,0"
alt="Home"
href="home.php">
<area shape="rect"
coords="60,30,104,0"
alt="join"
href="signup.html">
<area shape="rect"

coords="105,30,262,0"

alt="music"

href="music.html">
<area shape="rect"

coords="263,30,336,0"

alt="concerts"

href="concerts.html">
<area shape="rect"
coords="337,30,452,0"
alt="search"
href="profile search.html">
<area shape="rect"
coords="453,30,513,0"
alt="games"
href="games.php">
<area shape="rect"
coords="514,30,619,0"
alt="blogs"
href="blogs.html">
<area shape="rect"
coords="615,30,730,0"
alt="radio"
href="radio.html">
</map>
</div><h1 align="center">You are now registered! click <a href="home.html">here</a> to login</h1></body></html>';

mysql_close($con)
?>[/code] what might be wrong, since its giving me [code]Parse error: parse error in /Library/WebServer/Documents/users/cool21.php on line 11[/code] when I go to "myusername".php

Share this post


Link to post
Share on other sites
okay, I kind of fixed part of it, but now when it creates the file, there is missing data. in other words, I dont have what I have written in my creation file right. here is the file that creates the file
registration.php:
[code=php:0]
<?php
$con = mysql_connect("localhost","ZackBabtkis","");
$password = md5($_POST['password']);
$username = mysql_real_escape_string($_POST[username]) or die("no");
$about = mysql_real_escape_string($_POST[about]);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
$write = ("<html><body>
<title>Profile</title>
<body bgcolor=336699>
<div align=center>
<table width=332 cellpadding=0 cellspacing=3>
<tr>
<td background=tableo.jpg
style=border-top:3px red solid;border-bottom:3px red
solid;border-right:36px red solid;border-left:3px red solid;>
<?php
$user = $_COOKIE[user];
$con = @mysql_connect(localhost, ZackBabtkis, );
if (!$con)
  {
  die(Could not connect: . mysql_error());
  }
mysql_select_db(test, $con);

$result = mysql_query(SELECT about FROM users WHERE username = $user);

while($row = mysql_fetch_array($result))
  {
  echo $row[about];
  }

mysql_close($con);
?>
</td>
</tr>
</table>
</body>
</html>
");
$filename = "/Library/WebServer/Documents/users/$username.php";
$filehandle = fopen($filename, 'w') or die("can't create or open file");
fwrite($filehandle, $write);
fclose($filehandle);


mysql_select_db("test", $con);

$sql="INSERT INTO users
(username,password,first,last,email,phone,street,city,zip,state,country,month,day,year)
VALUES
('$_POST[username]','$password','$_POST[first]','$_POST[last]','$_POST[email]','$_POST[phone]','$_POST[street]','$_POST[city]','$_POST[zip]','$_POST[state]','$_POST[country]','$_POST[month]','$_POST[day]','$_POST[year]' )";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo '<html><title>Registered</title>
<body bgcolor="336699">
<div align="center">
<a href="home.html">
<embed src="YaddaYay_Banner.jpg">
</a>
<embed src="join.jpg" width="728" hight="30" usemap="#barmap">
<map id="barmap" name="barmap">
<area shape="rect"
coords="0,30,59,0"
alt="Home"
href="home.php">
<area shape="rect"
coords="60,30,104,0"
alt="join"
href="signup.html">
<area shape="rect"

coords="105,30,262,0"

alt="music"

href="music.html">
<area shape="rect"

coords="263,30,336,0"

alt="concerts"

href="concerts.html">
<area shape="rect"
coords="337,30,452,0"
alt="search"
href="profile search.html">
<area shape="rect"
coords="453,30,513,0"
alt="games"
href="games.php">
<area shape="rect"
coords="514,30,619,0"
alt="blogs"
href="blogs.html">
<area shape="rect"
coords="615,30,730,0"
alt="radio"
href="radio.html">
</map>
</div><h1 align="center">You are now registered! click <a href="home.html">here</a> to login</h1></body></html>';

mysql_close($con)
?>[/code]


and here is an example of the file it made, keep in mind that when I registered onn my page using register.php, my cookie name was cool21.
example.php:


[code=php:0]<html><body>
<title>Profile</title>
<body bgcolor=336699>
<div align=center>
<table width=332 cellpadding=0 cellspacing=3>
<tr>
<td background=tableo.jpg
style=border-top:3px red solid;border-bottom:3px red
solid;border-right:36px red solid;border-left:3px red solid;>
<?php
= cool21;
Resource id #2 = @mysql_connect(localhost, ZackBabtkis, );
if (!Resource id #2)
  {
  die(Could not connect: . mysql_error());
  }
mysql_select_db(test, Resource id #2);

= mysql_query(SELECT about FROM users WHERE username = );

while( = mysql_fetch_array())
  {
  echo ;
  }

mysql_close(Resource id #2);
?>
</td>
</tr>
</table>
</body>
</html>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.