Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > code ที่มัน Error ใครรู้ช่วยหน่อยครับ Code Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in



 

code ที่มัน Error ใครรู้ช่วยหน่อยครับ Code Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in

 



Topic : 026592



โพสกระทู้ ( 13 )
บทความ ( 0 )



สถานะออฟไลน์




Code

<?php
if (!isset($GET["y"])){
$year = date('Y');
}
else{
$year = $GET["y"];
}

$link = mysql_connect('localhost','root','191130');
if(!$link){
die('Could not connected'.mysql_error());
}
//echo 'Connected successfully';

mysql_select_db("radius");

/*
$strSql="SECECT Distinct GroupName FROM usergroup u";
$result = mysql_query($strSql);
echo $year;
echo "<table border = 1>";
while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
echo"<tr><td>".$row["GroupName"]."<td>";
for($month=1;$month<=12;$month++) {
$strSql2= " SELECT GroupName,Year(AcctStartTime)As year,Month(AcctStartTime)As month ,Count(*)As Count FROM radius.radacct, radius.usergroup u where radius.UserName= u.UserName Group by GroupName,Year(AcctStartTime),Month(AcctStarTime) Having year = ".$year."and month = ".Month."and GroupName = ".$row["GroupName"]."";
$result2 = mysql_query($strSql2);
$num_rows = mysql_num_rows($result2);
if($num_row == 0) {
$row2["Count"]=0;
}
else{
$row2=mysql_fetch_array($result2);
}
echo "<td>".$row2["Count"]."</td>";
}
echo "</tr>";
}
echo "</table>";
*/

$data =array();

$strSql="SELECT GroupName,Year(AcctStartTime)As year,Month(AcctStartTime)As month,Count(*)As count From radius.radacct,radius.Usergroup u where radacct.UserName = u.UserName Group by GroupName,Year(AcctStartTime),Month(AcctStarTime) Having year = ".$year."";

$result = mysql_query($strSql);

echo"<table border = 1>";
while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
echo "<tr>";
echo "<td>".$row["GroupName"]."</td>";
echo "<td>".$row["year"]."</td>";
echo "<td>".$row["month"]."</td>";
echo "<td>".$row["count"]."</td>";
echo "</tr>";
$data[$row["GroupName"]][$row["year"]][$row["month"]]=$row["count"];
}
echo "</table>";

echo $year;
echo "<table border = 1>";
echo "<tr>";
echo "<th>UserName</th>";
echo "<th>Jan</th>";
echo "<th>Feb</th>";
echo "<th>Mar</th>";
echo "<th>Apr</th>";
echo "<th>May</th>";
echo "<th>Jun</th>";
echo "<th>Jul</th>";
echo "<th>Aug</th>";
echo "<th>Sep</th>";
echo "<th>Oct</th>";
echo "<th>Nov</th>";
echo "<th>Dec</th>";
echo "</tr>";
foreach($data as $GroupName=>$val){
echo "<tr>";
echo "<td>$GroupName</td>";
foreach($val as $year=>$val2){
//print "Key $year,Value $val2\n";
//echo "<td>$year</td>";
//foreach($val2 as $month=>$val3){
for($month=1;$month<=12;$month++){
//echo "<td>$month =val3</td>";
//echo "<td>$val3</td>";
if(isset($data[$GroupName][$year][$month])){
echo "<td>".$data[$GruopName][$year][$month]."</td>";
}
else{
echo "<td>0</td>";
}
}
}
echo "</tr>";
}
echo "</table>";

mysql_free_result($result);
mysql_close($link)

?>

ปัญหาที่เกิด

1. Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Krasnoyarsk' for '7.0/no DST' instead in C:\AppServ\www\test.php on line 3

2. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\test.php on line 48
2009UserName Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

3. Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\test.php on line 98

ใครรู้ช่วยบอกหน่อยครับต้องแก้ตรงไหน



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-04-23 10:29:11 By : ragnaroknong View : 2208 Reply : 3
 

 

No. 1



โพสกระทู้ ( 182 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook Hi5 Blogger

Code (PHP)
<?php
if (!isset($_GET["y"])){ // แก้ตรงนี้
	$year = date('Y');
}else{
	$year = $_GET["y"]; // แก้ตรงนี้
}

$link = mysql_connect('localhost','root','191130');
if(!$link){
	die('Could not connected'.mysql_error());
}
//echo 'Connected successfully';

mysql_select_db("radius");

/*
$strSql="SECECT Distinct GroupName FROM usergroup u";
$result = mysql_query($strSql);
echo $year;
echo "<table border = 1>";
while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
echo"<tr><td>".$row["GroupName"]."<td>";
for($month=1;$month<=12;$month++) { 
$strSql2= " SELECT GroupName,Year(AcctStartTime)As year,Month(AcctStartTime)As month ,Count(*)As Count FROM radius.radacct, radius.usergroup u where radius.UserName= u.UserName Group by GroupName,Year(AcctStartTime),Month(AcctStarTime) Having year = ".$year."and month = ".Month."and GroupName = ".$row["GroupName"].""; 
$result2 = mysql_query($strSql2); 
$num_rows = mysql_num_rows($result2);
if($num_row == 0) {
$row2["Count"]=0;
}
else{
$row2=mysql_fetch_array($result2);
}
echo "<td>".$row2["Count"]."</td>";
}
echo "</tr>";
}
echo "</table>";
*/ 

$data =array(); // แล้วนี้array อะไร

$strSql="SELECT GroupName,Year(AcctStartTime)As year,Month(AcctStartTime)As month,Count(*)As count From radius.radacct,radius.Usergroup u where radacct.UserName = u.UserName Group by GroupName,Year(AcctStartTime),Month(AcctStarTime) Having year = ".$year."";

$result = mysql_query($strSql);

echo"<table border = 1>";
while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
echo "<tr>";
echo "<td>".$row['GroupName']."</td>";
echo "<td>".$row['year']."</td>";  
echo "<td>".$row['month']."</td>"; 
echo "<td>".$row['count']."</td>"; 
echo "</tr>";
$data[$row["GroupName"]][$row["year"]][$row["month"]]=$row["count"];// ลองดูตรงนี้หน่อยนะครับงงมากเลย
}
echo "</table>";

echo $year;
echo "<table border = 1>";
echo "<tr>";
echo "<th>UserName</th>";
echo "<th>Jan</th>";
echo "<th>Feb</th>";
echo "<th>Mar</th>";
echo "<th>Apr</th>";
echo "<th>May</th>";
echo "<th>Jun</th>";
echo "<th>Jul</th>";
echo "<th>Aug</th>";
echo "<th>Sep</th>";
echo "<th>Oct</th>";
echo "<th>Nov</th>";
echo "<th>Dec</th>";
echo "</tr>";
foreach($data as $GroupName=>$val){
echo "<tr>";
echo "<td>$GroupName</td>";
foreach($val as $year=>$val2){
//print "Key $year,Value $val2\n";
//echo "<td>$year</td>";
//foreach($val2 as $month=>$val3){
for($month=1;$month<=12;$month++){
//echo "<td>$month =val3</td>";
//echo "<td>$val3</td>";
if(isset($data[$GroupName][$year][$month])){
echo "<td>".$data[$GruopName][$year][$month]."</td>";
}
else{
echo "<td>0</td>";
}
}
}
echo "</tr>";
}
echo "</table>";

mysql_free_result($result);
mysql_close($link); // แก้ตรงนี้
?>


ก็ลองดูนะครับ บอกตรง ๆ ผมดูแล้วยังงงเลย






Date : 2009-04-23 13:07:27 By : mosaddzero
 


 

No. 2



โพสกระทู้ ( 913 )
บทความ ( 2 )



สถานะออฟไลน์
Facebook

ใช้ Appserv 2.6 ใช่ปะครับ
อิอิเปลี่ยนไปใช้ 2.5.9 จะดีกว่าครับ date() ใช้ไม่ได้ error แบบนั้นแหละ
Date : 2009-04-25 15:48:25 By : teez1232002
 

 

No. 3



โพสกระทู้ ( 519 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


ผมว่านะ

ข้อ 1 ลองแก้ใน php.ini ก่อนนะครับ บรรทัดที่ เขียนว่า "date.timezone"
ถ้าเจอ ";date.timezone =" ให้เปลี่ยนเป็น "date.timezone = Asia/Bangkok" ดูก่อนครับ
อาจจะแก้ปัญหาข้อ 1 ได้ (มั้ง แหะๆ)

ส่วนข้อ 2,3 เกิดจาก sql ที่คุณเขียน ผิด ทำให้ mysql_query แล้วไม่ได้ resource อะไรออกมา
mysql_fetch_array() ก็เลย error
mysql_free_result() ก็เลย error

ข้อแนะนำ
ให้ echo sql ออกมาแล้ว copy ไปลองรันใน phpMyAdmin ดู
ถ้า error มันก็จะบอกในนั้นเลยคับ
Date : 2009-04-25 16:18:35 By : nut_t02
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : code ที่มัน Error ใครรู้ช่วยหน่อยครับ Code Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่