MySql (PHP) warning free result
--> "Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource"
Het opslaan in de database werkt perfect, maar hij geeft wel deze error elke keer aan. Heeft iemand een idee waar dit door komt?
// PHP script
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
$link = @mysql_connect('servername', 'username', 'password');
if (!$link)
{
echo "Could not connect: " . mysql_error();
}
else
{
mysql_select_db('my_database');
$query = "INSERT INTO order_queue
( Name , Email , OtherInfo , qtyA ,
totalA , qtyB , totalB , qtyC , totalC , GrandTotal )";
$query .= " VALUES
('$Name', '$Email', '$OtherInfo', '$qtyA',
'$totalA', '$qtyB', '$totalB', '$qtyC', '$totalC', '$GrandTotal')";
//echo $query . "<br>\n";
$result = mysql_query($query)or die(mysql_error());
mysql_free_result($result);
mysql_close($link);
}
?>
$link = @mysql_connect('servername', 'username', 'password');
if (!$link)
{
echo "Could not connect: " . mysql_error();
}
else
{
mysql_select_db('my_database');
$query = "INSERT INTO order_queue
( Name , Email , OtherInfo , qtyA ,
totalA , qtyB , totalB , qtyC , totalC , GrandTotal )";
$query .= " VALUES
('$Name', '$Email', '$OtherInfo', '$qtyA',
'$totalA', '$qtyB', '$totalB', '$qtyC', '$totalC', '$GrandTotal')";
//echo $query . "<br>\n";
$result = mysql_query($query)or die(mysql_error());
mysql_free_result($result);
mysql_close($link);
}
?>
// MySql install code
CREATE TABLE `order_queue` (
`pid` INT(10) AUTO_INCREMENT,
`Name` varchar(100) NOT NULL,
`Email` varchar(255) NOT NULL,
`OtherInfo` varchar(255) NOT NULL,
`qtyA` varchar(100) NOT NULL,
`totalA` varchar(100) NOT NULL,
`qtyB` varchar(100) NOT NULL,
`totalB` varchar(100) NOT NULL,
`qtyC` varchar(100) NOT NULL,
`totalC` varchar(100) NOT NULL,
`GrandTotal` varchar(100) NOT NULL,
PRIMARY KEY (`pid`)
);
Gewijzigd op 01/01/1970 01:00:00 door Die hard
Foutafhandeling ontbreekt. Misschien is de query wel mislukt. Je weet het maar nooit.
ps. ik heb het veranderd hier $result = mysql_query($query)or die(mysql_error());
Gewijzigd op 01/01/1970 01:00:00 door die hard