Jump to content

Update php/sql not working.


lpollard

Recommended Posts

Hello all, I have tried the following syntax to update a record from the $_POST method, and I cannot get it to update the record. Can anyone spot where I'm going wrong in my code :confused:

 

<?php
$idstudent = $_POST["idstudent"];
$childname = $_POST["childname"];
$parentname = $_POST["parentname"];
$dated = $_POST["dated"];
$datem = $_POST["datem"];
$datey = $_POST["datey"];
$dob = $datey ."-". $datem ."-".$dated;
$age = $_POST["age"];
$lastupdate = date("Y\-m\-d");
$gender = $_POST["gender"];
$address1 = $_POST["address1"];
$address2= $_POST["address2"];
$city = $_POST["city"];
$postcode = $_POST["postcode"];
$phone = $_POST["phone"];
$mobile = $_POST["mobile"];
$email = $_POST["email"];
$pass= $_POST["password"];
$height = $_POST["height"];
$neck = $_POST["neck"];
$chest = $_POST["chest"];
$hips = $_POST["hips"];
$waist = $_POST["waist"];
$insideleg = $_POST["insideleg"];
$dress = $_POST["dress"];
$shoe = $_POST["shoes"];
$haircolour = $_POST["haircolour"];
$hairlength = $_POST["hairstyle"];
$eyes = $_POST["eyecolour"];
$ethnicity = $_POST["ethnicity"];
$image = $_POST["image"];
$approve = "0";
$actor = $_POST["actor"];
$standin = $_POST["standin"];
$voiceover = $_POST["voiceover"];
$stagecombat = $_POST["stagecombat"];
$daballet = $_POST["daballet"];
$dasalsa = $_POST["dasalsa"];
$dabreak = $_POST["dabreak"];
$dadisco = $_POST["dadisco"];
$dahiphop = $_POST["dahiphop"];
$dajazz = $_POST["dajazz"];
$damodern = $_POST["damodern"];
$dastreet = $_POST["dastreet"];
$datap = $_POST["datap"];
$dacontemp = $_POST["dacontemp"];
$dafreestyle = $_POST["dafreestyle"];
$daswing = $_POST["daswing"];
$dawaltz = $_POST["dawaltz"];

include ('../../source/db_config.php');
	$db = mysql_connect($host,$username,$password) or die(mysql_error()); 
	mysql_select_db($database, $db) or die(mysql_error());
$update = "UPDATE 'students' SET 'childname'='$childname', 'parentname'='$parentname', 'dob'='$dob', 'age'='$age', 
'lastupdate'='$lastupdate', 'gender'='$gender', 'address1'='$address1', 'address2'='$address2', 'city'='$city',
'postcode'='$postcode', 'phone'='$phone', 'mobile'='$mobile', 'email'='$email', 'password'='$pass', 
'height'='$height', 'neck'='$neck', 'chest'='$chest', 'hips'='$hips', 'waist'='$waist', 'insideleg'='$insideleg',
'dress'='$dress', 'shoe'='$shoe', 'haircolour'='$haircolour', 'hairlength'='$hairlength', 'eyes'='$eyes', 
'ethnicity'='$ethnicity', 'actor'='$actor', 'standin'='$standin', 'stagecombat'='$stagecombat', 'daballet'='$daballet', 
'dasalsa'='$dasalsa', 'dabreak'='$dabreak', 'dadisco'='$dadisco', 'dahiphop'='$dahiphop', 'dajazz'='$dajazz', 
'damodern'='$damodern', 'dastreet'='$dastreet', 'datap'='$datap', 'dacontemp'='$dacontemp',
'dafreestyle'='$dafreestyle', 'daswing'='$daswing', 'dawaltz'='$dawaltz' WHERE 'id'='$idstudent'";
mysql_query($update);
?>

 

Don't worry about the password either.. it is passed through md5 encryption.

 

But any help will be greatly appreciated  :thumb-up:

Link to comment
https://forums.phpfreaks.com/topic/248244-update-phpsql-not-working/
Share on other sites

I would echo the $update variable so that you can proofread it to make sure it contains what you think, such as a valid id value in the where clause.

 

You can also get php/mysql to tell you if/why a query is failing by using mysql_error() -

 

mysql_query($update) or die(mysql_error());

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.