Jump to content

Recommended Posts

I am fairly new to php but have been doing quite well at understand the php and mysql but i just cant seem to get the syntax right with the below sql statement.

 

$sql = mysql_query ("SELECT * FROM results WHERE resultteam='$team'" order by ID DESC LIMIT ".$Start.",".$pageLimit);

 

can anybody help please

Link to comment
https://forums.phpfreaks.com/topic/129383-solved-error-in-my-sql-staetement/
Share on other sites

No Im afraid it did not work just gave me a blank page like when the php script insnt working. There was no sql error either.

 

sql error in my syntax:

 

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 '5' at line 1

Ok now it validates but with the code i am using does not display any records but it works without that where statement. here is my code:

 

resultteam is my db field Varchar(45)

 

code:

 

<?php
$team=$_GET["t"];
$results=$_GET["results"];

If ($results=="final") {

include('dbinfo.php');	// connect to DB.
$conn = mysql_connect( $dbhost, $dbuser, $dbpass );
mysql_select_db($dbname);

$result = mysql_query("SELECT * FROM finaltable order by ID DESC");
$row = mysql_fetch_array($result) or die(mysql_error());
$finaltable=$row['finalresults'];

If ($finaltable==NULL) {
echo "<P>No Current Final Results Table<BR>Please Check Back At The End Of The Season</P>";
}else{
$finalresults = nl2br(htmlentities($finaltable));
echo "<P>";
echo "<B>BTFC Final Results Table 2008</B>";
echo "<br><br>";
echo $finalresults;
echo "</P>";
}

}else{

$team=$_GET["t"];
$results=$_GET["results"];
// Start Results Page

include('dbinfo.php');	// include your code to connect to DB.
$conn = mysql_connect( $dbhost, $dbuser, $dbpass );
mysql_select_db($dbname);

$noEntriesQuery = mysql_query("SELECT * FROM results") or die(mysql_error());

// read the number
$noEntries = mysql_num_rows($noEntriesQuery);

// set page limit
$pageLimit = 5;

// calculate the number of pages
$noPages = ceil($noEntries / $pageLimit);

// current page
$currentPage = 0;

// check if the $_GET value exists, if yes.. set the $currentPage to that value
if(isset($_GET['spag']) && 
    is_numeric($_GET['spag']) && 
    $_GET['spag'] > 0 && 
    $_GET['spag'] < $noPages){

// the test passed, set the current page
$currentPage = $_GET['spag'];

}

// start number
$start = $currentPage * $pageLimit;

// the query for the current page

$sql = "SELECT * FROM results WHERE 'resultteam'=$team' order by ID DESC LIMIT $Start,$pageLimit";
$result = mysql_query($sql,$conn);

if($sql){echo " Command is successful ";} 
else {echo "Command is not successful ";} 
echo $team;

// Start Results Loop
while($row = mysql_fetch_array($result))
	{
	echo "<BR>";
	echo $row['resultdate'];
	echo "<BR>";
	echo $row['resultdetails'];
	echo "<BR>";

	}

echo "<BR>";

// Query for number of pages

for($a = 0; $a < $noPages; $a++){
if($currentPage == $a){ 
	echo "PAGE";
	echo ($a+1);
}else{
	echo '<a class="pagelinks" href="'.$_SERVER['PHP_SELF'].'?content=results&results=match&t='.$team.'&spag='.$a.'">'.($a+1).'</a>';
}
if($a < $noPages - 1){
	echo '-';
}
}		

//End Results Page 
}

 

I presume this is still part of the same problem sorry if it is not considered part.

 

can anybody help

 

thank you for your help so far

 

can anybody help

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.