Parse Error/T_String?

SpaceshipSpaceship
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Watch

True_Snake

In-House Graphic DesignerVIP Member
Impact
67
Hi guys :) .

First, I'd like to let you know that I'm pretty new to PHP, so I don't really have an understanding of the language as of yet. I'm still learning :) .

Anyway, I was wondering if you could help me with the following:

I have a database with nearly 1 million businesses from the province of Ontario. Now I've uploaded this database to this site which hosts large databases.

Now the site I'm currently testing my stuff on is:
http://www.ovechkin.info/ontario/

You'll see a search thing on the page. When I enter nothing at all and press search, it takes me to the results page. That's fine.

But when I enter something into it, it says:

Code:
Parse error: syntax error, unexpected T_STRING in /home/snake/public_html/ontario/db.php on line 3

Now I for the life of me can't figure out what on earth that means :D .

I have 3 files for this thing:

(1)index.php (whose code I copied to the aforementioned link so that it can be in my template)

(2)db.php Below is it's contents
Code:
<?php
$db = mysql_connect("free-mysql.BizHostNet.com:3306", "1167951294", "MYPASSWORD"
mysql_select_db("1167951294", $this->conn)
?>

(3) results.php
Code:
<?php

$MATCHES_OVERRIDE = -1;    //set to -1 to disable override








function ReturnMatches($q, $city, $name, $matches, $first)
{

    global $MATCHES_OVERRIDE;

    if ($q) {
        if (!$first) {
            $first = 0;
        }
        if (!$matches) {
            //default
            $matches = 30;
        if (!$ads) {
            $ads = 0;
        }
        }

if ($MATCHES_OVERRIDE > 0) {
            $matches = $MATCHES_OVERRIDE;
        }

    
    include 'db.php';
   
$db = @mysql_connect($DATABASE_SERVER, $DATABASE_USER, $DATABASE_PASSWORD)
            or die("<br><b>Error connecting to database or server too busy: Try again later.</b>");// . mysql_error());
        mysql_select_db($DATABASE_NAME, $db);


        $query =  "SELECT List.* ";
        $query .= ",MATCH(keywords1, keywords2, city, name) AGAINST (' . $q . ' IN BOOLEAN MODE) AS Relevance  ";
        $query .= "FROM List ";
        $query .= "WHERE MATCH(keywords1, keywords2, city, name) AGAINST (' . $q . ' IN BOOLEAN MODE) HAVING Relevance > 0.03  ";

  $query .= "ORDER BY Relevance DESC ";
  $query .= "LIMIT " . $first . "," . $matches;








$result = mysql_query($query, $db)

            or die("<br><b>Error executing query: " . mysql_error() . "</b>\n");

        $row = mysql_fetch_array($result);

mysql_close($db);


echo "<html>	\n"; 
echo "<head>	\n"; 
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n"; 	
echo "<title>$q</title>	\n"; 
?>

<script language="JavaScript">
function blockError(){return true;}
window.onerror = blockError;
</script>




</head>
<body link="#000000" vlink="#808080" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" text="#30305A" bgcolor="#FFFFFF">


<?PHP


    



echo "<table width=\"100%\" background=\"background.gif\" cellspacing=\"0\" style=\"border-top:1px groove #C0C0C0; border-bottom-style:groove\"><tr><td width=\"33%\">\n";
echo " <font face='Verdana' color='#000040' size='1'>   <b>$q</b>\n";

echo " 	 <font color=\"#000000\" face=\"Verdana\" size=\"1\">Listings " . ($first+1) . "  to " . ($first+$matches) . "	\n"; 
echo "      </td>\n";


echo "<td width=\"64%\"><p align=\"right\"><b>\n";

	if ($first == 0) {
		echo "";
	} else {
		echo "<a style=\"text-decoration: none\" href=\"q.php?q=" . $q . "&matches=" . $matches . "&first=" . ($first-$matches) . "\" ><font face=\"Verdana\" size=\"1\" color='#000040'>Prev</a>  | ";
	}
	echo "   ";
	if ($no_results == 1) {
		echo "Next";
	} else {
	echo "<a style=\"text-decoration: none\" href=\"q.php?q=" . $q . "&matches=" . $matches . "&first=" . ($first+$matches) .  "\" ><font face=\"Verdana\" size=\"1\" color='#000040'>Next</a></font>  \n";
	}
echo "</td></tr></table></b>  \n";






      if ($first == 0) {
            echo "";
        } else {
            echo "";
        }


        if ($no_results == 1) {



echo "No More Results";




        } else {


    }



  $no_results = 0;
        if ($row) {
            do {








echo "<font face='verdana' size='2'>\n";
printf("<img src=\"clip.gif\"> <a href=\"businesspage.php?telephone=%s&geo=%s %s %s %s\" ><b>%s</b></a></font><br>  \n", $row["telephone"], $row["address"], $row["city"], $row["state"], $row["zip"], $row["name"]);
printf(" <font face='verdana' size='2'>    %s    \n", $row["address"]);
printf("  %s, %s %s</font><br>\n", $row["city"], $row["state"], $row["zip"]);
printf(" <font face='verdana' size='2'>    Tel: %s     Fax: %s</font><br>\n", $row["telephone"], $row["fax"]);
printf(" <font face='verdana' size='1'>    <b>Category:</b> %s // %s<br></font> \n", $row["keywords1"], $row["keywords2"]); 












            } while ($row = mysql_fetch_array($result));
        } else {
            $no_results = 1;
            echo "\n";
            if ($first == 0) {



            } else {
                echo "No more results found.<br>\n";

 
            }
        }

}
}

    ReturnMatches($q, $city, $name, $matches, $first);



     if ($first == 0) {
            echo "";
        } else {
            echo "";
        }


        if ($no_results == 1) {

 

echo "No More Results";



        } else {



    }




?>




</blockquote>
<p align="center">
<font face="Verdana" size="2">Copyright </font>
<font face="Times New Roman" size="2">(c)</font> <font face="Verdana" size="2">All Rights Reserved - YOUR BUSINESS NAME</font><br> 


</body></html>

What am I doing wrong?

Thanks and take care :)

True_Snake
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
$db = mysql_connect("free-mysql.BizHostNet.com:3306", "1167951294", "MYPASSWORD"

should be
$db = mysql_connect("free-mysql.BizHostNet.com:3306", "1167951294", "MYPASSWORD");

You're using "$this" without an Object

It should be mysql_select_db("1167951294", $db);


Just to be sure its

mysql_connect('localhost', 'mysql_user', 'mysql_password');
mysql_select_db("DATABASE_NAME", RESOURCE); <--resource is $db in your case
 
0
Close
Thanks :) !

Now I have:

Code:
<?php
$db = mysql_connect("free-mysql.BizHostNet.com:3306", "1167951294", "MYPASSWORD");
mysql_select_db("1167951294", $db);
?>

The error I have now:
Error connecting to database or server too busy: Try again later.

True_Snake
 
Last edited:
0
Close
Try again and see if it works.. Since it looks like your just using some free host, it probably is busy.
 
0
Close
Thanks for your support guys :) .

It still shows the same error.

The error has two parts: it could either be that there is an error connecting to the db or that the server is too busy. So it could still be the code?

Thanks,
True_Snake
 
0
Close
True_Snake said:
Thanks for your support guys :) .

It still shows the same error.

The error has two parts: it could either be that there is an error connecting to the db or that the server is too busy. So it could still be the code?

Thanks,
True_Snake
Its most likely the host is busy :)
 
0
Close
Might be too busy .. what's the query
 
0
Close
Well lets ignore that silly message since it has been set by the script creator and has no relevance tothe problem.

Replace:
PHP:
$db = @mysql_connect($DATABASE_SERVER, $DATABASE_USER, $DATABASE_PASSWORD)
            or die("<br><b>Error connecting to database or server too busy: Try again later.</b>");// . mysql_error());
        mysql_select_db($DATABASE_NAME, $db);

With:
PHP:
$db = @mysql_connect($DATABASE_SERVER, $DATABASE_USER, $DATABASE_PASSWORD) or die('Connection error: ' . mysql_error());

mysql_select_db($DATABASE_NAME, $db) or die('Cannot connect to database: ' . mysql_error());
That will output the true error/problem from the MySQL server.


Edit: Wait, why are we connecing twice? The fixed and included db.php will connect beforehand leaving these linds useless.
 
Last edited:
0
Close
nm ... i see what you mean in results.php ....
 
Last edited:
0
Close
Thanks Matt :) .

I updated results.php, and it says:

Connection error.

Thanks for your continued time and support guys :] .


True_Snake
 
0
Close
OK lets say sod it a bit and experiment.

New results.php
PHP:
<?php

$MATCHES_OVERRIDE = -1;    //set to -1 to disable override


function ReturnMatches($q, $city, $name, $matches, $first)
{

    global $MATCHES_OVERRIDE;

    if ($q) {
        if (!$first) {
            $first = 0;
        }
        if (!$matches) {
            //default
            $matches = 30;
        if (!$ads) {
            $ads = 0;
        }
        }

if ($MATCHES_OVERRIDE > 0) {
            $matches = $MATCHES_OVERRIDE;
        }

    
    	include 'db.php';


        $query =  "SELECT List.* ";
        $query .= ",MATCH(keywords1, keywords2, city, name) AGAINST (' . $q . ' IN BOOLEAN MODE) AS Relevance  ";
        $query .= "FROM List ";
        $query .= "WHERE MATCH(keywords1, keywords2, city, name) AGAINST (' . $q . ' IN BOOLEAN MODE) HAVING Relevance > 0.03  ";

  $query .= "ORDER BY Relevance DESC ";
  $query .= "LIMIT " . $first . "," . $matches;








$result = mysql_query($query, $db) or die("<br><b>Error executing query: " . mysql_error() . "</b>\n");

        $row = mysql_fetch_array($result);

mysql_close($db);


echo "<html>	\n"; 
echo "<head>	\n"; 
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n"; 	
echo "<title>$q</title>	\n"; 
?>

<script language="JavaScript">
function blockError(){return true;}
window.onerror = blockError;
</script>




</head>
<body link="#000000" vlink="#808080" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" text="#30305A" bgcolor="#FFFFFF">


<?PHP


    



echo "<table width=\"100%\" background=\"background.gif\" cellspacing=\"0\" style=\"border-top:1px groove #C0C0C0; border-bottom-style:groove\"><tr><td width=\"33%\">\n";
echo " <font face='Verdana' color='#000040' size='1'>   <b>$q</b>\n";

echo " 	 <font color=\"#000000\" face=\"Verdana\" size=\"1\">Listings " . ($first+1) . "  to " . ($first+$matches) . "	\n"; 
echo "      </td>\n";


echo "<td width=\"64%\"><p align=\"right\"><b>\n";

	if ($first == 0) {
		echo "";
	} else {
		echo "<a style=\"text-decoration: none\" href=\"q.php?q=" . $q . "&matches=" . $matches . "&first=" . ($first-$matches) . "\" ><font face=\"Verdana\" size=\"1\" color='#000040'>Prev</a>  | ";
	}
	echo "   ";
	if ($no_results == 1) {
		echo "Next";
	} else {
	echo "<a style=\"text-decoration: none\" href=\"q.php?q=" . $q . "&matches=" . $matches . "&first=" . ($first+$matches) .  "\" ><font face=\"Verdana\" size=\"1\" color='#000040'>Next</a></font>  \n";
	}
echo "</td></tr></table></b>  \n";






      if ($first == 0) {
            echo "";
        } else {
            echo "";
        }


        if ($no_results == 1) {



echo "No More Results";




        } else {


    }



  $no_results = 0;
        if ($row) {
            do {








echo "<font face='verdana' size='2'>\n";
printf("<img src=\"clip.gif\"> <a href=\"businesspage.php?telephone=%s&geo=%s %s %s %s\" ><b>%s</b></a></font><br>  \n", $row["telephone"], $row["address"], $row["city"], $row["state"], $row["zip"], $row["name"]);
printf(" <font face='verdana' size='2'>    %s    \n", $row["address"]);
printf("  %s, %s %s</font><br>\n", $row["city"], $row["state"], $row["zip"]);
printf(" <font face='verdana' size='2'>    Tel: %s     Fax: %s</font><br>\n", $row["telephone"], $row["fax"]);
printf(" <font face='verdana' size='1'>    <b>Category:</b> %s // %s<br></font> \n", $row["keywords1"], $row["keywords2"]); 












            } while ($row = mysql_fetch_array($result));
        } else {
            $no_results = 1;
            echo "\n";
            if ($first == 0) {



            } else {
                echo "No more results found.<br>\n";

 
            }
        }

}
}

    ReturnMatches($q, $city, $name, $matches, $first);



     if ($first == 0) {
            echo "";
        } else {
            echo "";
        }


        if ($no_results == 1) {

 

echo "No More Results";



        } else {



    }




?>




</blockquote>
<p align="center">
<font face="Verdana" size="2">Copyright </font>
<font face="Times New Roman" size="2">(c)</font> <font face="Verdana" size="2">All Rights Reserved - YOUR BUSINESS NAME</font><br> 


</body></html>

New db.php
PHP:
<?php
$db = mysql_connect("free-mysql.BizHostNet.com:3306", "1167951294", "MYPASSWORD") or die('Connection error' . mysql_error());
mysql_select_db("1167951294", $db);
?>

i am confused as to why the output was only "connection error" as i told it to output further information by adding mysql_error(). Makes me think that if this does not work now it may be a server problem.
 
0
Close
Thanks again for your time :) .

Now I get
Error executing query: Table '1167951294.list' doesn't exist

The URL that the error page is on is:
Code:
http://www.ovechkin.info/ontario/results.php?q=usaid&x=23&y=11

In the email I got from the hosting it said (if it matters):
Server Address : free-mysql.BizHostNet.com
Port : 3306
Database Name : 1167951294
User : 1167951294
Password : *MyPassword*

EDIT: When I query directly from PHPMyAdmin on the host's site, and I search for, lets say "Sound", it shows me:

Database 1167951294 running on localhost

Error

SQL-query :

Sound

MySQL said:

#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 'Sound' at line 1
:-/

Does it/could it have to do with the fact that my database is ~122 MB?

Thanks again,
True_Snake
 
Last edited:
0
Close
That's probably something in your syntax :hehe:

Ignore that for now, the important part is:

-- Table '1167951294.list' doesn't exist

Means exactly what it says, the database does not exist. Something is entered incorrectly somewhere. Check the database name and table name in phpmyadmin.
 
0
Close
Hey :) . Okay, I figured out that the table name is "on". Where does that go in the code? The database name is 1167951294.

Could it just be that I'm using a free host?

Thanks for your time guys :tu: !


True_Snake
 
0
Close
Nope, just the query line is wrong.

Replace:
PHP:
$query .= "FROM List ";

With:
PHP:
$query .= "FROM `on` ";

(that is in replace.php)

As you get used to and moe experienced in php (and to a certain extent mysql) you will get used to these little mistakes and will easily be able to fix them yourself :)
 
0
Close
God bless you Matt for your help :) .

I replaced it, and it shows me:
Error executing query: Unknown table 'List'

Does
Code:
$query =  "SELECT List.* ";
need to be changed to something else?

Thanks man, I know I'm taking a ton of time :].

True_Snake
 
0
Close
Ah, that's poor coding on the original creators side, didn't notice it since i would have never thought anyone would do it lol. That section is not needed for this query and should be:

PHP:
$query =  "SELECT * ";

Matt
 
0
Close
Hey, thanks :) .

Error executing query: Unknown column 'keywords1' in 'field list'

I'm not sure why I see this ^^?

But in results.php, there is:
Code:
$query .= ",MATCH(keywords1, keywords2, city, name) AGAINST (' . $q . ' IN BOOLEAN MODE) AS Relevance  "; $query .= "FROM `on` "; $query .= "WHERE MATCH(keywords1, keywords2, city, name) AGAINST (' . $q . ' IN BOOLEAN MODE) HAVING Relevance > 0.03  ";

It says MATCH(keywords1,keywords2,city,name) but on index.html, there is only one search field. Does that have something to do with it :-/?

Thanks again man.
True_Snake
 
0
Close
As arranged via chat here is a replacement (simpler) for you:

Untested, any problems (likely ;)) post back.

PHP:
<?php
include 'db.php';

if(strlen($_GET['q']) > 0)
{
	
	$search = mysql_real_escape_string( stripslashes($_GET['q']) );
	
	$query = mysql_query("SELECT * FROM `on` WHERE Name LIKE '%$search%'") or die(mysql_error());
	
	if(mysql_num_rows($query) > 0)
	{
		while($row = mysql_fetch_array($query))
		{
			echo '<div style="border-bottom: 1px solid #ddd">';
			
			echo "{$row['Name']}<br />
				  {$row['Address']}<br />
				  {$row['City']}<br />
				  {$row['State']}<br />
				  {$row['Zip/Postal']}<br />
				  {$row['phone']}<br />
				  {$row['BusCode']}<br />
				  {$row['SolicitFlag']}<br />
				  {$row['BusType']}<br />
				  {$row['URL']}<br />
				  {$row['Country']}<br />
				  
				  </div>";
		}
	}
	else
	{
			echo 'No records found';
	}
}
else
{
	echo 'Nothing submitted';
}
?>
 
Last edited:
0
Close
Thank you VERY VERY VERY VERY VERY much Matt :tu: ! It works :) ! Can't tell how happy I am.

Thank you to all of you guys :tu:!

God Bless :tu: !

Take care,
True_Snake
 
0
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back