Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
309 views
in Technique[技术] by (71.8m points)

php - Column count of mysql.proc is wrong. Expected 20, found 16. The table is probably corrupted

I am using 000webhost.com and I am using phpMyAdmin there. I am getting this error from MySQL when I run my PHP script as the title says:

Column count of mysql.proc is wrong. Expected 20, found 16.

The table is probably corrupted.

Is there any solution for this?

<?php
$username="usrname";
$password="passwd";
$database="a1xxxxx_mydb";
$host="mysqlxx.000webhost.com";
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
if (isset($_GET["userLatitude"]) && isset($_GET["userLongitude"])) {

 $userLatitude=$_GET['userLatitude']; 
 $userLongitude=$_GET['userLongitude']; 
 $result = mysql_query("SELECT locationName, ( 6371 * acos( cos( radians(floatval(     $userLatitude) )) * cos( radians( locationLatitude ) ) * cos( radians( locationLongitude ) - radians( floatval($userLatitude)) ) + sin( radians(floatval($userLongitude)) ) * sin( radians( locationLatitude) ) ) ) AS distance 
         FROM Location HAVING distance < 2 ORDER BY distance LIMIT 0 ,20") or die(mysql_error()); 
echo $result;

 // check for empty result
if (mysql_num_rows($result) > 0) {
   // looping through all results
   // products node
  $response["Location"] = array();

  while ($row = mysql_fetch_array($result)) {
    // temp user array
    $product = array();
    $product["locationName"] = $row["locationName"];
    $product["locationInfo"] = $row["locationInfo"];
    $product["locationLatitude"] = $row["locationLatitude"];
    $product["locationLongitude"] = $row["locationLongitude"];
    $product["locationPic"] = $row["locationPic"];
    $product["city"] = $row["city"];

    // push single product into final response array
    array_push($response["Location"], $product);
 }
 // success
 $response["success"] = 1;

   // echoing JSON response
   echo json_encode($response);
 } else {
// no products found
$response["success"] = 0;
$response["message"] = "No products found";

// echo no users JSON
echo json_encode($response);
 }
 }
  else {
    // required field is missing
   $response["success"] = 0;
   $response["message"] = "Required field(s) is missing";

  // echoing JSON response
  echo json_encode($response);
 }
mysql_close();
?>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had this error as well. I fixed it by running

mysql_upgrade -u root -p

Also, restart the mysql service by running

service mysqld restart

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...