yagami34
Supremacy Member
- Joined
- Aug 5, 2000
- Messages
- 7,207
- Reaction score
- 0
Hi there. I'm very very new to PHP programming and I had an annoying error on my website which kept displaying
'strict standards: only variables should be by reference in x:\www\xxx..\func.php on line 944'
function createMaterial($db) {
$material_code=$_POST["material_code"];
//$Type=$_POST["Type"];
$brand=$_POST["brand"];
$Type=$_POST["Type"];
$weight=$_POST["weight"];
$serializes=$_POST["serializes"];
try
{
$stmt = $db->prepare("SELECT * FROM material WHERE code = :code");
$stmt->bindParam(':code', $material_code, PDO:
ARAM_STR);
$stmt->execute();
$total = $stmt->rowCount();
if($total == 0)
{
$stmt = $db->prepare("INSERT INTO material (code, brand, weight, type, serialize) VALUES
code, :brand, :weight, :type, :serializes)");
$stmt->bindParam(':code', strtoupper($material_code));
$stmt->bindParam(':brand', strtoupper($brand));
$stmt->bindParam(':weight', $weight);
$stmt->bindParam(':type', $Type);
$stmt->bindParam(':serializes', $serializes);
$stmt->execute();
echo "<script type='text/javascript'>alert('Material added successfully');
window.location = './newmaterial.php'
</script>";
}
The highlighted line is the one that is said to have errors. I have another similar function which does the same thing but it doesnt have that error. I tried to compare the 2 when I cannot find any difference.
Is anyone able to help me? I need it for a presentation tomorrow.

'strict standards: only variables should be by reference in x:\www\xxx..\func.php on line 944'
function createMaterial($db) {
$material_code=$_POST["material_code"];
//$Type=$_POST["Type"];
$brand=$_POST["brand"];
$Type=$_POST["Type"];
$weight=$_POST["weight"];
$serializes=$_POST["serializes"];
try
{
$stmt = $db->prepare("SELECT * FROM material WHERE code = :code");
$stmt->bindParam(':code', $material_code, PDO:
$stmt->execute();
$total = $stmt->rowCount();
if($total == 0)
{
$stmt = $db->prepare("INSERT INTO material (code, brand, weight, type, serialize) VALUES
$stmt->bindParam(':code', strtoupper($material_code));
$stmt->bindParam(':brand', strtoupper($brand));
$stmt->bindParam(':weight', $weight);
$stmt->bindParam(':type', $Type);
$stmt->bindParam(':serializes', $serializes);
$stmt->execute();
echo "<script type='text/javascript'>alert('Material added successfully');
window.location = './newmaterial.php'
</script>";
}
The highlighted line is the one that is said to have errors. I have another similar function which does the same thing but it doesnt have that error. I tried to compare the 2 when I cannot find any difference.
Is anyone able to help me? I need it for a presentation tomorrow.
