Skip to main content
added 17 characters in body
Source Link
Michael Mrozek
  • 176.9k
  • 29
  • 172
  • 179

Say,I have a table defined like this:

create table users ( id int(10), age int(3), name varchar (50) )

create table users ( id int(10), age int(3), name varchar (50) ) 

I want to use a query to update just the ageage, which is an integer, that comes from an html form. When

When it arrives to the method that updates it, it comes as a string, so I change it to integer with phpPHP and try to update the table, but it doesn't work, any help? please?

$age=intval($age); $q2 = "UPDATE users SET age='$age' where username like '$username';"; mysql_query($q2,$con);

$age = intval($age); $q2 = "UPDATE users SET age='$age' where username like '$username';"; mysql_query($q2,$con); 

Say, have a table defined like this

create table users ( id int(10), age int(3), name varchar (50) )

I want to use a query to update just the age which is an integer, that comes from an html form. When it arrives to the method that updates it, it comes as a string, so I change it to integer with php and try to update the table but it doesn't work, any help? please?

$age=intval($age); $q2 = "UPDATE users SET age='$age' where username like '$username';"; mysql_query($q2,$con);

I have a table defined like this:

create table users ( id int(10), age int(3), name varchar (50) ) 

I want to use a query to update just age, which is an integer, that comes from an html form.

When it arrives to the method that updates it, it comes as a string, so I change it to integer with PHP and try to update the table, but it doesn't work

$age = intval($age); $q2 = "UPDATE users SET age='$age' where username like '$username';"; mysql_query($q2,$con); 
Source Link
lesolorzanov
  • 3.7k
  • 9
  • 40
  • 58

Updating an integer defined column in a MySQL DB with PHP

Say, have a table defined like this

create table users ( id int(10), age int(3), name varchar (50) )

I want to use a query to update just the age which is an integer, that comes from an html form. When it arrives to the method that updates it, it comes as a string, so I change it to integer with php and try to update the table but it doesn't work, any help? please?

$age=intval($age); $q2 = "UPDATE users SET age='$age' where username like '$username';"; mysql_query($q2,$con);