stalbergpar
asked on
Update MySQL error: mysql_fetch_row(): supplied argument is not a valid MySQL result resource
This is a page where I edit content from the database. And when I push the edit button: btn-edit I get this error:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /usr/local/psa/home/vhosts /monstera. se/httpdoc s/admin/ed it_promoto r.php on line 31
I cut and paste this code from another update page I built and there it works on that database table.
Can it be the encoding or something that is wrong or the header("location: playlist.php"); is wrong?
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /usr/local/psa/home/vhosts
I cut and paste this code from another update page I built and there it works on that database table.
Can it be the encoding or something that is wrong or the header("location: playlist.php"); is wrong?
<?php
include_once('inc/inc_top.php');
if(!isset($_SESSION['userid'])) header('location: index.php');
$id = @$_GET['id'];
if(isset($_POST['btn-edit'])) {
$club_name = ($_POST['club_name']);
$pro_name = ($_POST['pro_name']);
$pro_address = ($_POST['pro_address']);
$pro_postnr = ($_POST['pro_postnr']);
$pro_contact = ($_POST['pro_contact']);
$pro_tel = ($_POST['pro_tel']);
$pro_mail = ($_POST['pro_mail']);
$pro_web = ($_POST['pro_web']);
$pro_vat = ($_POST['pro_vat']);
$pro_orgnr = ($_POST['pro_orgnr']);
$capacity = ($_POST['capacity']);
$pro_city = ($_POST['pro_city']);
if(@mysql_query("UPDATE venue SET club_name '$club_name', pro_name = '$pro_name', pro_address ='$pro_address', pro_postnr = '$pro_postnr', pro_contact = '$pro_contact', pro_tel = '$pro_tel', pro_mail = '$pro_mail', pro_web = '$pro_web', pro_vat = '$pro_vat', pro_org = '$pro_org', capacity = '$capacity', pro_city = '$pro_city' WHERE id = $id;")) {
mysql_close();
header("location: playlist.php");
}
}
$sql = "SELECT club_name, pro_name, pro_address, pro_postnr, pro_contact, pro_tel, pro_mail, pro_web, pro_vat, pro_org, capacity, pro_city FROM venue WHERE id = $id";
$rows = mysql_query($sql);
while ($row = mysql_fetch_row($rows)){
$club_name = $row[0];
$pro_name = $row[1];
$pro_address = $row[2];
$pro_postnr = $row[3];
$pro_contact = $row[4];
$pro_tel = $row[5];
$pro_mail = $row[6];
$pro_web = $row[7];
$pro_vat = $row[8];
$pro_org = $row[9];
$capacity = $row[10];
$pro_city = $row[11];
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Solved it! Tnx !
It was a combination of things not just the club_name =...
And yes the code I posted was just a desperate cut and paste from another working application...
This is how the sql query is looking right now with a die print... and this is what I use...
It was a combination of things not just the club_name =...
And yes the code I posted was just a desperate cut and paste from another working application...
This is how the sql query is looking right now with a die print... and this is what I use...
if(@mysql_query($sql)) {
mysql_close();
header("location: playlist.php");
} else {
die(mysql_error());
}
And while you're at it, fix this!! This leaves you WIDE OPEN to SQL Injection hacking!!!
$id = @$_GET['id'];
@mysql_query("UPDATE venue SET .....WHERE id = $id;"))
If you don't know what SQL Injection hacking is, google it and do some reading until you understand, then use something like mysql_real_escape_string() to protect yourself.
$id = @$_GET['id'];
@mysql_query("UPDATE venue SET .....WHERE id = $id;"))
If you don't know what SQL Injection hacking is, google it and do some reading until you understand, then use something like mysql_real_escape_string()
@mysql_query and not using or die to print error message, this way, you will never know what's wrong