Jump to content


Photo

Need help getting this script running


  • Please log in to reply
13 replies to this topic

#1 cableuser

cableuser
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 23 June 2006 - 06:11 AM

Finally! I think I may have found a site that can help me with my problem. I am very much a noob at all this so dont try to give me any techno php lingo on how to go about things. I am pretty sure I am just missing something little but I have no idea what to look for so thats why I am here. I did actually get connected to the database though! I am proud of that accomplishment. [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] Now its just a matter of guess, test, and revise for me as I do not know what is supposed to be there and what is not. So now I am getting this:

Parse error: parse error, unexpected T_STRING in /home/www/maxabileousexchange.com/bannerrotator.php on line 16
That line of code goes as follows:

mysql_select_db("xxxxxxxxxx_xxx") or die("Could not select database")

Ok here is the entire code

<?

// This script is copyrighted to Pullan Enterprises
// You are not allowed to copy this script
// If you modify this script you may not claim copyrights.  
// You are not allowed to remove this header
// We will take legal action against all violators.  


function brotator($br_rid) {
foreach (array_keys($GLOBALS) as $i) {if(!isset(${$i})) global ${$i};}
$br_exptype = "Date (YYYYMMDDHHMMSS)";
if (!$db) {
$db = mysql_pconnect("xxxxxxx", "xxxxxxxx", "xxxxxx") or die("Could not connect")

mysql_select_db("xxxxxxxx") or die("Could not connect")
}
    $br_updatesql = "UPDATE bannerrotator SET status='Expired' WHERE exptype='$br_exptype' AND expires<=$now";

  $br_updateresult = mysql_query($br_updatesql);
$br_sql2 = "SELECT * FROM bannerrotator WHERE adgroup='$br_rid' AND status='Normal' ORDER BY RAND() LIMIT 1";
    $br_result2 = mysql_query($br_sql2) or die("Query failed");

    $br_myrow2 = mysql_fetch_array($br_result2);
$br_tid = $br_myrow2["id"];
$br_newviews = $br_myrow2["views"] + 1;
if ($br_myrow2["exptype"] == "Views" && $br_newviews == $br_myrow2["expires"]) {

    $br_sql3 = "UPDATE bannerrotator SET views=views+1,status='Expired'  WHERE id='$br_tid'";

} else {
    $br_sql3 = "UPDATE bannerrotator SET views=views+1 WHERE id='$br_tid'";

}
  $br_result3 = mysql_query($br_sql3) or die("Query failed");

if ($br_myrow2["type"] == "HTML") {
echo $br_myrow2["html"];
} elseif ($br_myrow2["type"] == "Image") {
?>
<a href="<?php echo $url ?>/bclick.php?go=<?php echo $br_myrow2["id"] ?>" target="_blank"><img src="<?php echo $br_myrow2["image"] ?>" ALT="<?php echo $br_myrow2["alt"] ?>" border="0" height="<?php echo $br_myrow2["ih"] ?>" width="<?php echo $br_myrow2["iw"] ?>"></a>
<?php
}
}
    ?>

I am assuming I am missing an some little puntuation of some sort so please advise. Thanks

#2 paul2463

paul2463
  • Members
  • PipPipPip
  • Advanced Member
  • 955 posts
  • LocationUK

Posted 23 June 2006 - 10:43 AM

Hello

I am a noobie too but I think I may have found your fault, your line16 code printed below has a fault
mysql_select_db("xxxxxxxxxx_xxx") or die("Could not select database")

I think what it should read is the following

mysql_select_db('xxxxxxxxxx_xxx') or die("Could not select database")

note the single quote marks around the databse name
that should clear the fact that it found T_STRING marks where it wasnt expecting them

have a go anyway, its cant be made any worse by that change but I think that is the problem
(apart from any spelling mistakes made by me in this post for which there is an amnesty)
you cannot affect the past but you can ruin a perfectly good present by worrying about the future

*********************************************************************
The <A HREF="http://www.php.net/d...php">MANUAL</A> is actually a useful resource

#3 cableuser

cableuser
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 23 June 2006 - 01:06 PM

I will try that, thank you.

Edit: I tried that but it still does not work.

#4 paul2463

paul2463
  • Members
  • PipPipPip
  • Advanced Member
  • 955 posts
  • LocationUK

Posted 23 June 2006 - 01:53 PM

try this one for size then, I have tried to run the script and to clear the faults I changed your script to the following

if (!$db) {
$db = mysql_pconnect("xxxxxxx", "xxxxxxxx", "xxxxxx") or die("Could not connect");

mysql_select_db("xxxxxxxx") or die("Could not connect");
}

notice the semi-colon's at the end of the two lines of code in the IF statement, the errors went away but I dont know if the script fully works, you will though as you will have all the databsae names etc for it to connect to

hope it helps anyway
you cannot affect the past but you can ruin a perfectly good present by worrying about the future

*********************************************************************
The <A HREF="http://www.php.net/d...php">MANUAL</A> is actually a useful resource

#5 cableuser

cableuser
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 24 June 2006 - 12:59 AM

Ok thanks. That problem is fixed. Now the only error I get is a query failed whatever that means. Please tell me what I should do to fix a query failed error. Thanks

#6 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 24 June 2006 - 01:35 AM

"Query failed" is a pretty useless error message as it doesn't provide anything worth knowing. For test purposes, change your code to generate a useful error message and then you'll know where to look to fix it (or we will). For example, adjust your query lines from:
$br_result2 = mysql_query($br_sql2) or die("Query failed");

to this:
$br_result2 = mysql_query($br_sql2) or die("Error: ". mysql_error(). " with query ". $br_sql2);

Make a similar change to the other query/queries and tell us exactly what you get.
Legend has it that reading the manual never killed anyone.
My site

#7 cableuser

cableuser
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 24 June 2006 - 03:30 PM

Ok, just adding the little thing you told be to the br_result one. I know get this error message.

Error: Table 'bertschkid_max.bannerrotator' doesn't exist with query SELECT * FROM bannerrotator WHERE adgroup='Main' AND status='Normal' ORDER BY RAND() LIMIT 1

#8 cableuser

cableuser
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 24 June 2006 - 04:22 PM

$dbhost = '50webs.net'

MySQL said: Documentation
#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '$dbhost = '50webs.net'' at line 1

this could be what is wrong. for some reason this line is wrong but I do not know why please advise.

#9 paul2463

paul2463
  • Members
  • PipPipPip
  • Advanced Member
  • 955 posts
  • LocationUK

Posted 24 June 2006 - 04:28 PM

[!--quoteo(post=387492:date=Jun 24 2006, 11:22 AM:name=cableuser)--][div class=\'quotetop\']QUOTE(cableuser @ Jun 24 2006, 11:22 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
$dbhost = '50webs.net' //this is the line you typed

$dbhost = '50webs.net'' //this is the documentation line in your post

[/quote]

the fault could be one of two things in my mind
1. either the error is the fact that you have a single quote at the start of 50webs.net and a double quote at the end.

2. you are missing the ; at the end of the statement

have a look at the first one and see if there is a mix of quote marks otherwise try option 2

you cannot affect the past but you can ruin a perfectly good present by worrying about the future

*********************************************************************
The <A HREF="http://www.php.net/d...php">MANUAL</A> is actually a useful resource

#10 cableuser

cableuser
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 24 June 2006 - 04:49 PM

There is no double quotes at the end I do not know why the error message says I have double quotes but I do not. I just checked the php files. Also I do have a ; at the end of the statement. This doesnt make any since as I am positive what is in the mysql file is 100% correct. Here I will post what I have in there.

$dbhost = 'xxxxx.xxx';
$dbuser = 'xxxxxxxxxx_xxx';
$dbpass = 'xxxxxxxxx';
$dbport = '3306';
$conn = mysql_connect(xxxxxx.xxx, xxxxxxxxxx_xxx, xxxxxxxxx) or die                      ('Error connecting to mysql');

$dbname = 'xxxxxxxxxx_xxx';
mysql_select_db(xxxxxxxxxx_xxx);


#11 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 24 June 2006 - 06:36 PM

Unless your's is a pretty weird server set-up, the host is almost always 'localhost'. try $dbhost = 'localhost';

I'd assumed you were NOT having any problem connecting to the database since you posted a query error report.

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Error: Table 'bertschkid_max.bannerrotator' doesn't exist[/quote]

That's pretty clear. Maybe you have the database name wrong, maybe you have the table name wrong. The names are case-sensitive.
Legend has it that reading the manual never killed anyone.
My site

#12 cableuser

cableuser
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 24 June 2006 - 07:19 PM

50webs.net is the site where I get my hosting from. The site says what login info I am supposed to use and I entered it in exactly as it said. I tried using local host but with same results as before.

#13 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 24 June 2006 - 08:31 PM

There are forty php files in that zip!! I'd suggest you either post a request for help in the freelancing forum and offer something in exchange for getting it working, or ask for help at the site where you got the script in the first place.
Legend has it that reading the manual never killed anyone.
My site

#14 cableuser

cableuser
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 24 June 2006 - 08:42 PM

I finally got the script working. I cant believe how much of an idiot I am as it had nothing to do with the script I just uploaded the wrong file to the database. Silly me [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users