i have a mistake in my code
) Fatal error: Call to undefined function pg_num_rows() in C:\QG\www\medical-clinic\manip\updateProduit.php on line 49
Call Stack
# Time Memory Function Location
1 0.0019 386752 {main}( ) ..\updateProduit.php:0I use PHP5 MYSQL Here is my original code, i don’t know why it doesn’t word:
//VERIFICATION SI PRODUIT EXISTE
$query = “
SELECT `panier`.`idProduit`
FROM `panier`, `produit`
WHERE `Produit`.`nom` = ‘$nom’
AND `panier`.`idPanier` = “.$_SESSION["tempPanierSpec"].”
AND `produit`.`idProduit` = AND `panier`.`idProduit`
“;
$result = mysql_query($query);
$numRows = pg_num_rows($result); //NOMBRE DE ROW (DONNEES) DANS LA REPONSE
//SI N’EXISTE PAS
if($numRows == 0){
mysql_query(“SELECT `produit`.`idProduit` FROM `produit` WHERE `produit`.`nom` = ‘$nom’”);
while($row = mysql_fetch_array($result)){ $_SESSION["tempIdProd"] = $row["idProduit"]; }//WHILE
mysql_query(“INSERT INTO Panier (idPanier, idProduit, qte)
VALUES (‘”.$_SESSION["panierSpec"].”‘, ‘”.$_SESSION["tempIdProd"].”‘, ‘$qte’)”);
}
//SI EXISTE
else{
while($row = mysql_fetch_array($result)){ $_SESSON["tempIdProd"] = $row["idProduit"];}
$query = “
UPDATE `panier`
SET `panier`.`qte` = `panier`.`qte` + $qte
WHERE `panier`.`idPanier` = ‘”.$_SESSION["tempPanierSpec"].”‘
AND `panier`.`idProduit` = “. $_SESSION["tempidProd"];
mysql_query($query);
} Thanks to all
…………………………………..
You need to use mysql_num_rows($result) — pg_num_rows($result) is only for PostreSQL, hence the name.
…………………………………..
pg_num_rows is for postgres, to fix this, you can change to mysql_num_rows
imho, in order to outstanding from other answers
your server does not configured/installed with postgres module
based on your latest comment, if seems that you are passing an invalid SQL
…………………………………..
pg_num_rows is PostgreSQL function, try using mysql_num_rows instead.
$link = mysql_connect(“localhost”, “mysql_user”, “mysql_password”);
mysql_select_db(“database”, $link);
$result = mysql_query(“SELECT * FROM table1″, $link);
$num_rows = mysql_num_rows($result);
echo “$num_rows Rows\n”;
?>
…………………………………..
pg_num_rows is a function which takes a PostgreSQL resource and outputs the number of rows associated with it. It requires the PostgreSQL drivers for PHP, which do not come natively enabled with most simple WAMP installs. Many of them, actually, do not come with Postgre drivers at all.
Your other problem is that you’re passing in a MySQL resource to a Postgre function. That won’t work. Try mysql_num_rows.