Jump to content

Archived

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

runnerjp

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

Recommended Posts

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

[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);


}


?>[/code]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.");

Share this post


Link to post
Share on other sites
so if i took of the or die("Could not connect.");

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

Share this post


Link to post
Share on other sites
No, don't take it off. Just do what Orio said: Take off the semi-colon.

Share this post


Link to post
Share on other sites
Taking another look just replace a couple lines above with this:
[code]$dbname = "runnerse_shoutbox";
mysql_connect($host,$dbuser,$dbpass) or die("Could not connect: ".mysql_error());[/code]

Share this post


Link to post
Share on other sites
the new code looks like this


[code]<?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);


}


?>[/code]

yet it still keeps comein up with no db :S

here is marquee to bd if that helps

[code]<?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>";
?>[/code]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[code]$db=mysql_connect($host,$dbuser,$dbpass) or die("Could not connect: ".mysql_error());[/code]
Just noticed you're not storing the resource returned.

Share this post


Link to post
Share on other sites
Look at the variable "$db"

[code]
<?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");
[/code]

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

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

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

Like Yesideez said in an earlier post.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 [url=http://www.runnerselite.com]www.runnerselite.com[/url] 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

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.