Jump to content


Photo

error with script :(:(:( is n e 1 good here who can help ??


  • Please log in to reply
15 replies to this topic

#1 runnerjp

runnerjp
  • Members
  • PipPipPip
  • Advanced Member
  • 2,214 posts

Posted 22 August 2006 - 07:24 PM

Parse error: syntax error, unexpected T_LOGICAL_OR in /home/runnerse/public_html/chatbox/connect.php on line 5

thats the issue

here is the code

<?php
$host   = "localhost";
$dbuser = "runnerse";
$dbpass = "runnerjp2003";
$dbname = "runnerse_shoutbox"; or die("Could not connect.");
mysql_connect($host,$dbuser,$dbpass) or die(mysql_error());
// Select the database.
mysql_select_db($dbname) or die(mysql_error());



if(!$db)


        die("no db");


if(!mysql_select_db("runnerse_chatbox",$db))


         die("No database selected.");


if(!get_magic_quotes_gpc())


{


  $_GET = array_map('mysql_real_escape_string', $_GET);


  $_POST = array_map('mysql_real_escape_string', $_POST);


  $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);


}


else


{


   $_GET = array_map('stripslashes', $_GET);


   $_POST = array_map('stripslashes', $_POST);


   $_COOKIE = array_map('stripslashes', $_COOKIE);


   $_GET = array_map('mysql_real_escape_string', $_GET);


   $_POST = array_map('mysql_real_escape_string', $_POST);


   $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);


}


?>


#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 22 August 2006 - 07:26 PM

Change:
$dbname = "runnerse_shoutbox"; or die("Could not connect.");

To:
$dbname = "runnerse_shoutbox" or die("Could not connect.");


You see, the problem was you added a semicolon before the "or die...".
Tho I dont understand how the "or die(...)" part helps you.

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 22 August 2006 - 07:26 PM

Yeah what the guy above said.
What is the CoronaMatrix?

#4 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 22 August 2006 - 07:28 PM

The semi-colon marks the end of the piece of code.

$dbname = "runnerse_shoutbox";
Is valid on its own but this doesn't make sense:
or die("Could not connect.");
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#5 runnerjp

runnerjp
  • Members
  • PipPipPip
  • Advanced Member
  • 2,214 posts

Posted 22 August 2006 - 07:30 PM

so if i took of the or die("Could not connect.");

it will work...thanks guy 4 thery fast reply

#6 Jeremysr

Jeremysr
  • Members
  • PipPipPip
  • Advanced Member
  • 199 posts
  • LocationSaskatchewan, Canada

Posted 22 August 2006 - 07:31 PM

No, don't take it off. Just do what Orio said: Take off the semi-colon.

#7 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 22 August 2006 - 07:34 PM

just remove the "or die("...")"
What is the CoronaMatrix?

#8 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 22 August 2006 - 07:36 PM

Taking another look just replace a couple lines above with this:
$dbname = "runnerse_shoutbox";
mysql_connect($host,$dbuser,$dbpass) or die("Could not connect: ".mysql_error());

Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#9 runnerjp

runnerjp
  • Members
  • PipPipPip
  • Advanced Member
  • 2,214 posts

Posted 22 August 2006 - 07:44 PM

the new code looks like this


<?php
$host   = "localhost";
$dbuser = "myusername";
$dbpass = "mypassword";
$dbname = "runnerse_chatbox";
mysql_connect($host,$dbuser,$dbpass) or die("Could not connect: ".mysql_error());
// Select the database.
mysql_select_db($dbname) or die(mysql_error());



if(!$db)


        die("no db");


if(!mysql_select_db("runnerse_chatbox",$db))


         die("No database selected.");


if(!get_magic_quotes_gpc())


{


  $_GET = array_map('mysql_real_escape_string', $_GET);


  $_POST = array_map('mysql_real_escape_string', $_POST);


  $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);


}


else


{


   $_GET = array_map('stripslashes', $_GET);


   $_POST = array_map('stripslashes', $_POST);


   $_COOKIE = array_map('stripslashes', $_COOKIE);


   $_GET = array_map('mysql_real_escape_string', $_GET);


   $_POST = array_map('mysql_real_escape_string', $_POST);


   $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);


}


?>

yet it still keeps comein up with no db :S

here is marquee to bd if that helps

<?php
#################################
include("chatbox/connect.php");
#################################

mysql_connect($host,$dbuser,$dbpass) or die(mysql_error());
// Select the database.
mysql_select_db($dbname) or die(mysql_error());
$query = "SELECT poster, message FROM ch_messages order by id DESC LIMIT 5";
$result = mysql_query($query);
$marquee = "";
while($r=mysql_fetch_array($result))
{
   $marquee.= $r[poster]. ''. $r[message]. '</a>';
}
echo "<marquee><font size='3'>". $marquee. "</font></marquee>";
?>


#10 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 22 August 2006 - 07:45 PM

The reason you are getting "no db" is because you are checking the variable $db which is set to nothing when you get to the if statement.
What is the CoronaMatrix?

#11 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 22 August 2006 - 07:46 PM

$db=mysql_connect($host,$dbuser,$dbpass) or die("Could not connect: ".mysql_error());
Just noticed you're not storing the resource returned.
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#12 runnerjp

runnerjp
  • Members
  • PipPipPip
  • Advanced Member
  • 2,214 posts

Posted 22 August 2006 - 07:59 PM

surey
$dbname = "runnerse_chatbox";

wud mean that the db is set to nothing :S

#13 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 22 August 2006 - 08:02 PM

Look at the variable "$db"

<?php
$host   = "localhost";
$dbuser = "myusername";
$dbpass = "mypassword";
$dbname = "runnerse_chatbox";
mysql_connect($host,$dbuser,$dbpass) or die("Could not connect: ".mysql_error());
// Select the database.
mysql_select_db($dbname) or die(mysql_error());



if(!$db)
   die("no db");

You never actually set it to anything in your code.  Change the line:

mysql_connect($host,$dbuser,$dbpass) or die("Could not connect: ".mysql_error());

To:
$db = mysql_connect($host,$dbuser,$dbpass) or die("Could not connect: ".mysql_error());

Like Yesideez said in an earlier post.
What is the CoronaMatrix?

#14 runnerjp

runnerjp
  • Members
  • PipPipPip
  • Advanced Member
  • 2,214 posts

Posted 22 August 2006 - 08:06 PM

YEEEEEEEEEEEEEEEEEEEEEEEEEY IT WORKS

i would just like to thank you all for you help!!!

if at any point i can offer a fav in any of your diractions i will help as much as i can....thank you again

#15 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 22 August 2006 - 08:10 PM

No problem... glad to help :)
What is the CoronaMatrix?

#16 runnerjp

runnerjp
  • Members
  • PipPipPip
  • Advanced Member
  • 2,214 posts

Posted 22 August 2006 - 08:15 PM

ok i know im gonna be a pain in ass but as im on a role i wanna know ... is their a way of separatin the name and message the some space cos at mo if you look www.runnerselite.com it comes as one lol and could i add a picture like my logo in between each diff comment ??? or is that all 2 hard to do




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users