 |
[PHP]
PHP มีปัญหาเรื่อง Fatal error: Uncaught TypeError: array_search(): Argument #2 |
|
 |
|
|
 |
 |
|
ERROR เต็มครับ
Fatal error: Uncaught TypeError: array_search(): Argument #2 ($haystack) must be of type array, null given in C:\xampp\htdocs\thipseafood\staff\cart\cook_cart\order.php:15 Stack trace: #0 C:\xampp\htdocs\thipseafood\staff\cart\cook_cart\order.php(15): array_search('162', NULL) #1 {main} thrown in C:\xampp\htdocs\thipseafood\staff\cart\cook_cart\order.php on line 15
Code (PHP)
01. <?php
02. ob_start();
03. session_start();
04.
05. if (!isset( $_SESSION [ "intLine" ])) {
06. if (isset( $_POST [ "txtProductID" ])) {
07. $_SESSION [ "intLine" ] = 0;
08. $_SESSION [ "strProductID1" ][0] = $_POST [ "txtProductID" ];
09.
10. $_SESSION [ "strQty" ][0] = $_POST [ "txtQty" ];
11.
12. header( "location:show.php" );
13. }
14. } else {
15. $key = array_search ( $_POST [ "txtProductID" ], $_SESSION [ "strProductID1" ]);
16. if ((string) $key != "" ) {
17. $_SESSION [ "strQty" ][ $key ] = $_SESSION [ "strQty" ][ $key ] + $_POST [ "txtQty" ];
18. } else {
19.
20. $_SESSION [ "intLine" ] = $_SESSION [ "intLine" ] + 1;
21. $intNewLine = $_SESSION [ "intLine" ];
22. $_SESSION [ "strProductID1" ][ $intNewLine ] = $_POST [ "txtProductID" ];
23. $_SESSION [ "strQty" ][ $intNewLine ] = $_POST [ "txtQty" ];
24. }
25.
26. header( "location:show.php" );
27. }
28. ?>
คิดว่าเหตุผลที่ ERROR เพราะผมลองเปลี่ยนชื่อ SESSION เป็น $_SESSION["strProductID1"] จากเดิม $_SESSION["strProductID"]
ไม่ทราบว่าจะแก้ไขยังไงดีครับ ขอบคุณล่วงหน้าครับ
Tag : PHP, XAMPP
|
|
 |
 |
 |
 |
Date :
2021-03-24 22:55:09 |
By :
dellboy1160 |
View :
3644 |
Reply :
13 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากครับ
|
 |
 |
 |
 |
Date :
2021-03-25 13:29:10 |
By :
dellboy1160 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ต้องแก้ยังไงครับ
Fatal error: Uncaught TypeError: mysqli_error(): Argument #1 ($mysql) must be of type mysqli, string given in F:\XAMPP\htdocs\Project\1\website\process2.php:37 Stack trace: #0 F:\XAMPP\htdocs\Project\1\website\process2.php(37): mysqli_error('INSERT INTO che...') #1 {main} thrown in F:\XAMPP\htdocs\Project\1\website\process2.php on line 37
Code (VB.NET)
01. <strong>Code (PHP)</strong>
02. <span class= "\"notranslate\"" ><font class= "css_code" ><pre class= "\"brush:php\"" >include
03.
04. print_r ($_POST);
05.
06. $img = $_POST[
07. $name = $_POST[
08. $phonenumber = $_POST[
09. $bath = $_POST[
10. $banks = $_POST[
11. $date = $_POST[
12. $time= $_POST[
13.
14. $data = "INSERT INTO checkpay
15. (
16. inpFile,
17. name,
18. phone,
19. money,
20. select,
21. day,
22. time
23. )
24. VALUES
25. (
26.
27.
28.
29.
30.
31.
32.
33. )
34. ";
35.
36. $resu = mysqli_query($conn, $data) or die( "Error in sql : $data" .
37. mysqli_error($data));
38.
39. mysqli_close($conn);
40.
41. </pre></font></span>
|
 |
 |
 |
 |
Date :
2021-07-21 04:20:19 |
By :
Tester |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
บรรทัดที่ 37 เขียนผิดครับ mysqli_error($data) เป็นเป็น mysqli_error($conn)
|
 |
 |
 |
 |
Date :
2021-07-21 09:05:38 |
By :
{Cyberman} |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมพลาดอะไรไปรึป่าวครับผมลองแก้แล้วขึ้นเหมือนเดิม
Error in sql : INSERT INTO checkpay ( Name, Phonenumber, Bath, Banks, Date, Time, Images ) VALUES ( 'Tester 12334', '0915467888', '500', 'SCB', '2021-07-06', '15:33' 'btn3.png' ) Column count doesn't match value count at row 1

Code (PHP)
01. <?php
02.
03. include 'connect2.php' ;
04.
05.
06. $name2 = $_POST [ 'name' ];
07. $phonenumber = $_POST [ 'phone' ];
08. $bath = $_POST [ 'bath' ];
09. $banks = $_POST [ 'banks' ];
10. $date = $_POST [ 'dmy' ];
11. $time = $_POST [ 'timer' ];
12. $image = $_POST [ 'images' ];
13.
14.
15. $data = "INSERT INTO checkpay
16. ( Name, Phonenumber, Bath, Banks, Date , Time, Images )
17. VALUES
18. (
19. '$name2' ,
20. '$phonenumber' ,
21. '$bath' ,
22. '$banks' ,
23. '$date' ,
24. '$time'
25. '$image'
26. )
27. ";
28.
29. $resu = mysqli_query( $conn , $data ) or die ( "Error in sql : $data" .
30. mysqli_error( $conn ));
31.
32. mysqli_close( $conn );
33.
34. ?>
35. <?php
36. require_once ( 'wait.php' );
37. ?>
|
 |
 |
 |
 |
Date :
2021-07-21 14:22:51 |
By :
Tester |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Column count doesn't match value count at row 1
คอมม่า หายไปตัว
|
ประวัติการแก้ไข 2021-07-21 14:54:10
 |
 |
 |
 |
Date :
2021-07-21 14:52:14 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Fatal error: Uncaught TypeError: mysqli_fetch_array(): Argument #1 ($result) must be of type mysqli_result, bool given in F:\XAMPP\htdocs\Project\admin\register\login.php:11 Stack trace: #0 F:\XAMPP\htdocs\Project\admin\register\login.php(11): mysqli_fetch_array(false) #1 {main} thrown in F:\XAMPP\htdocs\Project\admin\register\login.php on line 11
<?php
include_once('function.php');
$userdata = new DB_con();
if (isset($_POST['login'])){
$uname = $_POST['username'];
$password= $_POST['password'];
$result = $userdata->signin($uname, $password);
$num = mysqli_fetch_array($result);
if ($num > 0) {
$_SESSION['id'] = $num ['id'];
$_SESSION['fname'] = $num ['fullname'];
echo "<script>alert('Login Successful!');</script>";
echo "<script>window. location.href='orderlist.php'</script>";
} else {
echo "<script>alert('Login Failed!');</script>";
echo "<script>window. location.href='login.php'</script>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We"
crossorigin="anonymous">
</head>
<body>
<div class="container">
<form method="POST">
<h1>Login</h2>
<hr>
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">User Name</label>
<input type="text" class="form-control" id="username" name="username">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password">
</div>
<button type="submit" class="btn btn-primary" name="login">Login</button>
</form>
</div>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.3/dist/umd/popper.min.js" integrity="sha384-eMNCOe7tC1doHpGoWe/6oMVemdAVTMs2xqW4mwXrXsW0L84Iytr2wi5v2QjrP/xp" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.min.js" integrity="sha384-cn7l7gDp0eyniUwwAZgrzD06kc/tftFf19TOAs2zVinnD/C7E91j9yyk5//jjpt/" crossorigin="anonymous"></script>
</body>
</html>
|
 |
 |
 |
 |
Date :
2021-08-09 22:22:23 |
By :
Tester |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยทีครับ
Fatal error: Uncaught TypeError: mysqli_fetch_array(): Argument #1 ($result) must be of type mysqli_result, bool given in F:\XAMPP\htdocs\Project\admin\register\login.php:11 Stack trace: #0 F:\XAMPP\htdocs\Project\admin\register\login.php(11): mysqli_fetch_array(false) #1 {main} thrown in F:\XAMPP\htdocs\Project\admin\register\login.php on line 11
Code (VB.NET)
01. <?php
02. include_once(
03.
04. $userdata = new DB_con();
05.
06. if (isset($_POST[
07. $uname = $_POST[
08. $password= $_POST[
09.
10. $result = $userdata->signin($uname, $password);
11. $num = mysqli_fetch_array($result);
12.
13. if ($num > 0) {
14. $_SESSION[
15. $_SESSION[
16. echo "<script>alert('Login Successful!');</script>" ;
17. echo "<script>window. location.href='orderlist.php'</script>" ;
18. } else {
19. echo "<script>alert('Login Failed!');</script>" ;
20. echo "<script>window. location.href='login.php'</script>" ;
21. }
22. }
23. ?>
24.
25. <!DOCTYPE html>
26. <html lang= "en" >
27. <head>
28. <meta charset= "UTF-8" >
29. <meta http-equiv= "X-UA-Compatible" content= "IE=edge" >
30. <meta name= "viewport" content= "width=device-width, initial-scale=1.0" >
31. <title>Login</title>
33. crossorigin= "anonymous" >
34. </head>
35. <body>
36. <div class= "container" >
37. <form method= "POST" >
38. <h1>Login</h2>
39. <hr>
40. <div class= "mb-3" >
41. <label for= "exampleInputEmail1" class= "form-label" >User Name</label>
42. <input type= "text" class= "form-control" id= "username" name= "username" >
43. </div>
44. <div class= "mb-3" >
45. <label for= "exampleInputPassword1" class= "form-label" >Password</label>
46. <input type= "password" class= "form-control" id= "password" name= "password" >
47. </div>
48. <button type= "submit" class= "btn btn-primary" name= "login" >Login</button>
49. </form>
50.
51. </div>
52.
53.
54.
55. <script src= "https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.3/dist/umd/popper.min.js" integrity= "sha384-eMNCOe7tC1doHpGoWe/6oMVemdAVTMs2xqW4mwXrXsW0L84Iytr2wi5v2QjrP/xp" crossorigin= "anonymous" ></script> 56. <script src= "https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.min.js" integrity= "sha384-cn7l7gDp0eyniUwwAZgrzD06kc/tftFf19TOAs2zVinnD/C7E91j9yyk5//jjpt/" crossorigin= "anonymous" ></script> 57. </body>
58. </html>
|
 |
 |
 |
 |
Date :
2021-08-09 22:25:14 |
By :
Arno |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Oops! หาโค้ด VB ไม่เจอ 
เข้าไปแก้ SQL statement ในเมธอด DB_con::signin()
ส่วนแก้ไขว่าอย่างไรหารู้ได้ไม่ ด้วยหามีผู้ใดมองเห็นคลาสล่องหน
แม้นจักรู้ลึกตื้นหนาบาง จงสู้นำอาวุธมาปะกันที่ลานประลอง
|
 |
 |
 |
 |
Date :
2021-08-10 04:47:54 |
By :
TheGreatGod_of_Death |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เราสามารถเรียกไฟล์ BLOB จาก Database(Mysql) มาขึ้นโชว์บนหน้าเว็บได้มั้ยครับ ถ้าได้ต้องทำยังไงบ้างหรอครับ
อันนี้คือันที่ผมลองเขียนดู
Code (VB.NET)
01. <?php
02. $connection = mysqli_connect( "localhost" , "root" , "" );
03. $db = mysqli_select_db($connection,
04.
05. $query = " SELECT * FROM `checkpay` " ;
06. $query_run = mysqli_query($connection,$query);
07.
08. while($row = mysqli_fetch_array($query_run))
09. {
10. ?>
11.
12. <tr>
13. <td><?php echo $row[
14. <td><?php echo $row[
15. <td><?php echo $row[
16. <td><?php echo $row[
17. <td><?php echo $row[
18. <td><?php echo $row[
19. <td><?php echo $row[
20. <td><?php echo
21. </tr>
22. <?php } ?>
23. <?php
24. }
25. ?>
แต่มันขึ้นแบบนี้ครับ

|
 |
 |
 |
 |
Date :
2021-08-31 10:24:14 |
By :
Arno |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมอยากเอาราคามาคูณ จำนวน แต่ราคาตอนนี้ value มันรวมกับขนาดอยู่ ผมควรแก้ยังไงดีครับ
Code (VB.NET)
01. <label for= "size" >ขนาดป้าย</label>
02. <select name= "select" id= "size" required>
03. <option id= "size" name= "slct" value= "" selected> เลือกขนาดป้ายไวนิล</option>
04. <option id= "size" name= "slct1" value= "1x1 เมตร,ราคา 200บาท" > 1x1 เมตร ราคา 200 บาท</option>
05. <option id= "size" name= "slct2" value= "1x2 เมตร,ราคา 300บาท" >1x2 เมตร ราคา 300 บาท</option>
06. <option id= "size" name= "slct3" value= "1x3 เมตร,ราคา 450บาท" > 1x3 เมตร ราคา 450 บาท</option>
07. <option id= "size" name= "slct4" value= "1.20x2.40 เมตร,ราคา 450บาท" > 1.20x2.40 เมตร ราคา 450 บาท</option>
08. <option id= "size" name= "slct5" value= "1.50x3 เมตร,ราคา 750บาท" > 1.50x3 เมตร ราคา 750 บาท</option>
09. <option id= "size" name= "slct6" value= "2x4 เมตร,ราคา 1,200บาท" > 2x4 เมตร ราคา 1,200 บาท</option>
10. </select><br>
11.
12. <label for= "amou" >จำนวน</label>
13. <input type= "text" id= "amount" name= "amount" placeholder= "จำนวน" required><br>
|
 |
 |
 |
 |
Date :
2021-08-31 16:01:07 |
By :
Arno |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|