Forum Moderators: coopster

Message Too Old, No Replies

need help with mysql and php

         

paul123456

2:45 pm on Sep 10, 2004 (gmt 0)

10+ Year Member



hi

this error is appearing Parse error: parse error, unexpected T_VARIABLE in and i dont know what i am doing wrong. this is the code:-

<?
error_reporting (0);
$host="#*$!xxxxxx";
$user="xxx";
$password="xxxxxx";

$db = mysql_select_db("log",$link)
$link = mysql_connect($host,$user,$password);
if($link) {
die ('Could Not Connect To Server');

if($db); {
$query = "SELECT * FROM errors";
$result = mysql_query($query);
}
{
or die ("Couldn't execute query.");
}
{
echo "<h1>List For errors added so far.</h1>";
echo "<table cellspacing='15'>";
echo " <tr><td colspan='3'><hr></td><tr>";
while ($row = mysql_fetch_arry($result))
}
{
extract($row);
echo "<tr>\n
<td>.$row[ERROR_ID].</td>\n
<td>.$row[name].</td>\n
<td>.$row[error].</td>\n
</tr>\n";
}
?>

what could be wrong

thanks

mincklerstraat

2:55 pm on Sep 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to webmasterworld! first have a lookie at:
[webmasterworld.com...]

change:

$db = mysql_select_db("log",$link)
>
$db = mysql_select_db("log",$link);

and your next error will be at this line:
if($db); {
>
if($db) {

or rather, change that whole block of code to:
if($db) {
$query = "SELECT * FROM errors";
$result = mysql_query($query);
}
else {
die ("Couldn't execute query.");
}

You'll get more errors, too, in all likelihood; I think it's probably best you sat down with the php manual or a book and learned a bit more about general php syntax.

Sorry for the rtfmishness but here there's not much of an alternative. If you're out of time there's always rentacoder.

SkyDog

2:58 pm on Sep 10, 2004 (gmt 0)

10+ Year Member



Brackets and such are a bit of a mess. See comments in code

<?
error_reporting (0);
$host="#*$!#*$!#*$!";
$user="#*$!";
$password="xxxxxx";

$db = mysql_select_db("log",$link);//<-need the added semicolon here
$link = mysql_connect($host,$user,$password);
if(!$link) {
die ('Could Not Connect To Server');}//add ending bracket and change to if not (!) $link

if($db); {
$query = "SELECT * FROM errors";
$result = mysql_query($query);
}
{
or die ("Couldn't execute query."); //may want to use else block here
}
//{remove this bracket
echo "<h1>List For errors added so far.</h1>";
echo "<table cellspacing='15'>";
echo " <tr><td colspan='3'><hr></td><tr>";
while ($row = mysql_fetch_arry($result))
//} remove this bracket
{
extract($row);
echo "<tr>\n
<td>.$row[ERROR_ID].</td>\n
<td>.$row[name].</td>\n
<td>.$row[error].</td>\n
</tr>\n";
}
?>

[edited by: jatar_k at 5:04 pm (utc) on Sep. 10, 2004]

paul123456

12:22 am on Sep 12, 2004 (gmt 0)

10+ Year Member



thanks i sorted it do it a different way

tnaks again