Jump to content


Photo

profile about section


  • Please log in to reply
5 replies to this topic

#1 RTS

RTS
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 11 August 2006 - 06:52 PM

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
Parse error: parse error in /Library/WebServer/Documents/userlog.php on line 11
when I open it
heres the 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,);
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>


#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 11 August 2006 - 06:53 PM

You have an ending php tag (?>) which doesnt seem to have an opeing PHP tag. Remove ?> from line 11.

#3 RTS

RTS
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 11 August 2006 - 07:00 PM

okay, but I still get the same error on line 11

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 11 August 2006 - 07:05 PM

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


#5 RTS

RTS
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 11 August 2006 - 07:24 PM

okay, that kind of worked. it gave me the background and the table with
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /Library/WebServer/Documents/userlog.php on line 14
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.
<?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)
?>
what might be wrong, since its giving me
Parse error: parse error in /Library/WebServer/Documents/users/cool21.php on line 11
when I go to "myusername".php

#6 RTS

RTS
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 11 August 2006 - 09:33 PM

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


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:


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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users