MyBB Community Forums

Full Version: How to update counts in database?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Simply update in database with this file is not working. the query works fine in php myadmin.


<?php

$con=mysql_connect("localhost","arslan","arslan");	//conecting to database
if(!$con)

{

die("not conect".mysql_error());
}

mysql_selectdb("arslan",$con);	// selecting database


//taking url of download file

$urlForFile="SELECT * FROM `test` WHERE `links` LIKE '%dro%'";

$queryForFIleUrl=mysql_query($urlForFile);


while($row=mysql_fetch_array($queryForFIleUrl))		// geting complete url of download file
{

$orignalUrl=$row['links'];		// strong value for url in variable

}


//geting value from download link, and passing it to counter function and chaning header to url of download file.





echo "Current count:" .counter(). " <a href='/count.php?action=increment' target='_blank'>Download</a>";

if (isset($_GET['action']) == 'increment')
{
    
	updata();
	header("Location:$orignalUrl");
}


function updata()

{

mysql_query("update test set counts = counts + 1 where links like '%tes%'");

}




//counter function

function counter()
{


 $geting="SELECT `counts` FROM `test` WHERE `links` LIKE '%tes%'";		//queries local to function

$geting_counts=mysql_query($geting);


		while($row=mysql_fetch_array($geting_counts))
			{

				
				echo $row['counts'];


			}
	

}




?>






Remove the back ticks. They're not needed.
What?
^ backticks --> `[/b] {as in [b]SELECTcounts`}