runnerjp Posted August 22, 2006 Share Posted August 22, 2006 Parse error: syntax error, unexpected T_LOGICAL_OR in /home/runnerse/public_html/chatbox/connect.php on line 5thats 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] Quote Link to comment Share on other sites More sharing options...
Orio Posted August 22, 2006 Share Posted August 22, 2006 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. Quote Link to comment Share on other sites More sharing options...
Corona4456 Posted August 22, 2006 Share Posted August 22, 2006 Yeah what the guy above said. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted August 22, 2006 Share Posted August 22, 2006 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."); Quote Link to comment Share on other sites More sharing options...
runnerjp Posted August 22, 2006 Author Share Posted August 22, 2006 so if i took of the or die("Could not connect.");it will work...thanks guy 4 thery fast reply Quote Link to comment Share on other sites More sharing options...
Jeremysr Posted August 22, 2006 Share Posted August 22, 2006 No, don't take it off. Just do what Orio said: Take off the semi-colon. Quote Link to comment Share on other sites More sharing options...
Corona4456 Posted August 22, 2006 Share Posted August 22, 2006 just remove the "or die("...")" Quote Link to comment Share on other sites More sharing options...
Yesideez Posted August 22, 2006 Share Posted August 22, 2006 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] Quote Link to comment Share on other sites More sharing options...
runnerjp Posted August 22, 2006 Author Share Posted August 22, 2006 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 :Shere 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] Quote Link to comment Share on other sites More sharing options...
Corona4456 Posted August 22, 2006 Share Posted August 22, 2006 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. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted August 22, 2006 Share Posted August 22, 2006 [code]$db=mysql_connect($host,$dbuser,$dbpass) or die("Could not connect: ".mysql_error());[/code]Just noticed you're not storing the resource returned. Quote Link to comment Share on other sites More sharing options...
runnerjp Posted August 22, 2006 Author Share Posted August 22, 2006 surey $dbname = "runnerse_chatbox";wud mean that the db is set to nothing :S Quote Link to comment Share on other sites More sharing options...
Corona4456 Posted August 22, 2006 Share Posted August 22, 2006 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. Quote Link to comment Share on other sites More sharing options...
runnerjp Posted August 22, 2006 Author Share Posted August 22, 2006 YEEEEEEEEEEEEEEEEEEEEEEEEEY IT WORKSi 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 Quote Link to comment Share on other sites More sharing options...
Corona4456 Posted August 22, 2006 Share Posted August 22, 2006 No problem... glad to help :) Quote Link to comment Share on other sites More sharing options...
runnerjp Posted August 22, 2006 Author Share Posted August 22, 2006 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.