2016-09-05 2 views
-1

Qamp를 사용하는 동안 오류가 발생하지 않고 Wamp를 사용할 때 이러한 사용되지 않는 오류가 발생하여이 쿼리 또는 스크립트가 제대로 작동하게 만들 수 있습니까? 내가지고있어 오류 또는 경고가 나는 빈 페이지를 가지고 일부 연결 코드를 변경할 때 내 PHP 스크립트Wamp 경고 사용되지 않는 mysql 코드에 대한 경고

<?php 
$con = mysql_connect("localhost","root",""); 

if (!$con) { 
    die('Could not connect: ' . mysql_error()); 
} 

mysql_select_db("db", $con); 

$result = mysql_query("SELECT gender as gender_occupation, COUNT(*) as total FROM hostel_blocks GROUP BY gender"); 

$rows = array(); 
while($r = mysql_fetch_array($result)) { 
    $row[0] = $r[0]; 
    $row[1] = $r[1]; 
    array_push($rows,$row); 
} 

print json_encode($rows, JSON_NUMERIC_CHECK); 

mysql_close($con); 
?> 

입니다이 그림 enter image description here

에 있습니다.

+1

당신은 * mysqli 할 수있는 mysql을 변경해야 또는 PDO는 – FullStack

답변

0

PHP mysql은 PHP 5.5에서 더 이상 사용되지 않으며 PHP 7에서 제거되었습니다. 대신 mysqli로 이동해야합니다.

과 같을 것이다 mysqli를 사용하여 코드 :.

<?php 
    $con = mysqli_connect("localhost","root",""); 

    if (!$con) { 
     die('Could not connect: ' . mysqli_error($con)); 
    } 

    mysqli_select_db($con, "db"); 

    $result = mysqli_query($con, "SELECT gender as gender_occupation, COUNT(*) as total FROM hostel_blocks GROUP BY gender"); 

    $rows = array(); 
    while($r = mysqli_fetch_array($result)) { 
     $row[0] = $r[0]; 
     $row[1] = $r[1]; 
     array_push($rows,$row); 
    } 

    print json_encode($rows, JSON_NUMERIC_CHECK); 

    mysqli_close($con); 
    ?> 
+0

메신저 아직도 2 개 이상의 매개 변수를 공유 – benebake

+0

기대 ..... mysqli_query 활용하기 여기 코드 좀주세요. –

관련 문제