hello
i was wondering if anybody could shed some light for me on the fact as to why i keep getting the following error code all throughout my page..
i know its on about the mysrl_real_escape_string but i dont understand what is wrong with the code.. everything its asking the database for exists but for some reason it wont work.

<?php
// dit stuk script moet straks voor het tonen per league. schrijft de fixtures (gespeelde wedstrijden) naar de competition tabel
// dit is de quert om de competitie tabel qua scores leeg te maken
$empty_sql = 	"UPDATE competition, league ".
		"SET competition.won = '0', competition.draw = '0', competition.lost = '0', competition.for = '0', competition.against = '0' ".
		"WHERE competition.league_id = league.league_id ".
		"AND league.league_name = '" . mysql_real_escape_string ($league) . "' ";

	//echo "$empty_sql<br>";
mysql_query($empty_sql);


// deze query haalt de fixtures van 1 league en 1 jaar op , vervolgens zullen deze doorlopen worden en in de competition tabel weggeschreven worden;
$sql = "SELECT league.league_name, fixtures_result.hometeam_id, fixtures_result.awayteam_id, ".
  		"fixtures_result.home_result, fixtures_result.away_result, fixtures_result.fixture_ignore FROM ".
  		"fixtures_result ".
  		"INNER JOIN league ON (fixtures_result.league_id = league.league_id) WHERE ".
  		"(league.league_name = '" . mysql_real_escape_string($league) . "') ";
  		//echo $sql;
$result = mysql_query($sql);
while ($row = mysql_fetch_row($result)) {
	// nog controleren op leeg en of 0 ook zo wordt opgevat
	if (is_numeric($row[3]) and is_numeric($row[4]) AND $row[5]=="no"){

	//opbouwen dynamische update query voor home team
	$sql_update_home =  "UPDATE competition, league SET ";

	if ($row[3] > $row[4]){
		$sql_update_home .= " competition.won = competition.won + 1, ";
	}elseif ($row[3] < $row[4]){
			$sql_update_home .= " competition.lost = competition.lost + 1, ";
	}elseif ($row[3] == $row[4]){
			$sql_update_home .= " competition.draw = competition.draw + 1, ";
	}
	$sql_update_home .=	"competition.for = competition.for + $row[3], ".
						"competition.against = competition.against + $row[4] ".
						"WHERE competition.team_id = $row[1] ".
						"AND competition.league_id = league.league_id ".
						"AND league.league_name = '$league' ";

	mysql_query($sql_update_home);

	//opbouwen dynamische update query voor away team
	$sql_update_away =  "UPDATE competition, league SET ";
	if ($row[3] < $row[4]){
			$sql_update_away .= " competition.won = competition.won + 1, ";
	}elseif ($row[3] > $row[4]){
			$sql_update_away .= " competition.lost = competition.lost + 1, ";
	}elseif ($row[3] == $row[4]){
			$sql_update_away .= " competition.draw = competition.draw + 1, ";
	}
	$sql_update_away .=	"competition.for = competition.for + $row[4], ".
						"competition.against = competition.against + $row[3] ".
						"WHERE competition.team_id = $row[2] ".
						"AND competition.league_id = league.league_id ".
						"AND league.league_name = '$league' ";

	//echo "<br>away: $sql_update_away<br>";
	mysql_query($sql_update_away);
// voor als een wedstrijd abandoned is dan moet iedereen verliezen
}elseif ($row[5]=="yes"){
	$sql_abandoned_home = "UPDATE competition, league SET competition.lost = competition.lost + 1 ".
					"WHERE competition.team_id = $row[1] AND competition.league_id = league.league_id ".
					"AND league.league_name = '" . mysql_real_escape_string($league) . "' ";
	mysql_query($sql_abandoned_home);
	$sql_abandoned_away = "UPDATE competition, league SET competition.lost = competition.lost + 1 ".
					"WHERE competition.team_id = $row[2] AND competition.league_id = league.league_id ".
					"AND league.league_name = '" . mysql_real_escape_string($league) . "' ";
	mysql_query($sql_abandoned_away);


}
}
?>

does anybody have any suggestions to sorting this issue out please?
cheers in advance 😃

    i was wondering if anybody could shed some light for me on the fact as to why i keep getting the following error code all throughout my page..

    You never tell us what the error is. How can we identify what its about?

      Derokorian;10994663 wrote:

      You never tell us what the error is. How can we identify what its about?

      sorry my bad

      Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /homepages/2/d398538194/htdocs/headtohead/uitrekenen_leagues.php on line 7

      Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /homepages/2/d398538194/htdocs/headtohead/uitrekenen_leagues.php on line 7

      Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /homepages/2/d398538194/htdocs/headtohead/uitrekenen_leagues.php on line 10

      Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /homepages/2/d398538194/htdocs/headtohead/uitrekenen_leagues.php on line 10

      Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /homepages/2/d398538194/htdocs/headtohead/uitrekenen_leagues.php on line 18

      Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /homepages/2/d398538194/htdocs/headtohead/uitrekenen_leagues.php on line 18

      Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /homepages/2/d398538194/htdocs/headtohead/uitrekenen_leagues.php on line 20

      Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /homepages/2/d398538194/htdocs/headtohead/uitrekenen_leagues.php on line 20

      Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /homepages/2/d398538194/htdocs/headtohead/uitrekenen_leagues.php on line 21

        Roger Ramjet;10994667 wrote:

        More specificaly, mysql_real_escape_string uses the mysql library from your mysql server, so you have to connect to that server before calling the function. See the manual for notes abolut this http://uk.php.net/manual/en/function.mysql-real-escape-string.php

        yes that gave me the suggestion to use intval instead which corrected that problem.
        im just left with the following errors now fom original code post 1

        :-

        Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /homepages/2/d398538194/htdocs/headtohead/uitrekenen_leagues.php on line 10

        Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /homepages/2/d398538194/htdocs/headtohead/uitrekenen_leagues.php on line 10

        Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /homepages/2/d398538194/htdocs/headtohead/uitrekenen_leagues.php on line 19

        Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /homepages/2/d398538194/htdocs/headtohead/uitrekenen_leagues.php on line 19

        Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /homepages/2/d398538194/htdocs/headtohead/uitrekenen_leagues.php on line 20

          Same question as before:

          bradgrafelman;10994665 wrote:

          Where do you ever connect to MySQL?

            bradgrafelman;10994674 wrote:

            Same question as before:

            in the header of the document with an included config file

              What included config file? Your code above includes no config file, and the error messages suggest that there was no connection made prior to calling mysql_query().

                angelclawdust;10994672 wrote:

                use intval instead which corrected that problem.

                Which is not only fine, but what you absolutely should do - for integers. However, for strings you will still need to use mysql_real_escape_string. How you handle your data has nothing to do with wether a function happens to work or not in a particular case, you still should use the correct one. Thereafter making each necessary way of handling data work becomes necessary.

                  johanafm;10994714 wrote:

                  Which is not only fine, but what you absolutely should do - for integers. However, for strings you will still need to use mysql_real_escape_string. How you handle your data has nothing to do with wether a function happens to work or not in a particular case, you still should use the correct one. Thereafter making each necessary way of handling data work becomes necessary.

                  yup im not brill at this php/mysql but im getting there lol
                  sorted out the query now as didnt realise needed the connection on the same page as part of the code...
                  so thats that one figured out - thanks for the hint in the right direction guys 😃
                  if i need anymore help ill start a new thread if i cant find a solution save 3 or 4 different qs not related to thread title 🆒

                    Write a Reply...