Jump to content

Another update question


backinblack

Recommended Posts

I know there are alot of people that have asked about updates and I have read most of them. It seems to me I have the same thing as alot of people and they got there to work. Mine will not update it. It acts like it did but it don't. I have four columns in my database--driver_id, carnumber, name, april15pts(more dates will be added later)Car Numbers and names are already in there. I just want to update the april15pts column. Here is what I have.

I have a form with the text areas carnumber, name, and april15pts which goes to this process page.

 

<?php
	$carnumber = $_POST['carnumber'];
	$name = $_POST['name'];
	$april15pts = $_POST['april15pts'];

$host = "xxxxxxx";
$user = "xxxxxxx";
$password = "xxxxxx";
$database = "xxxxxxx";
$connection = mysql_connect($host, $user, $password)
    or die ("Could not retrieve information");
$db = mysql_select_db("databasename",$connection)
    or die ("Could not make connection");

$query = "UPDATE points SET 
		april15pts='$april15pts'
		 WHERE carnumber='$carnumber' AND  name='$name'";	


$results=mysql_query($query)
or die (mysql_error());
if ($results);

echo 'Result have been posted into database!';
?>

I have read that you are not suppose to use AND --and just use a comma but when I do that I get an error.

What the heck am I doing wrong?

Link to comment
Share on other sites

Well I ran it in phpmyadmin and it does nothing. It just shows that no rows were affected which I already knew. For some reason I do not think it reconizes the $april15pts variable. I can put any thing else in there like 50 and it will update then. I am confused. Please help.

Link to comment
Share on other sites

I have just two rows of three input fields now but it will be up to 25.

<form action="april15pts.php" method="post">
<table width="30%"><tr><td width="5%"><b>Car #:</b> </td><td width="15%"><b>Name:</b></td> <td width="5%"><b>Points:</b></td></tr>
<td><input type="text" name="carnumber[]"></td><td><input type="text" name="name[]"></td><td><input type="text" name="april15pts[]"></td></tr>
<tr><td><input type="text" name="carnumber[]"></td><td><input type="text" name="name[]"></td><td><input type="text" name="april15pts[]"></td></tr>
<tr><td><input type="submit" value="Send Results"></td></tr>
</table>
</form>

Link to comment
Share on other sites

It is never a really good idea to use numbers in variable or column names to be honest. I would change the april15pts to aprilfiftpts or something like that, or do aprilpts15. Yes it works alot of times, but sometimes that is the cause of the errors is the incompatibility.  I am just quoting this from memory, I could be wrong but yea.

 

Try to change the column name in the DB to something different and see if it works.

 

--FrosT

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.