Page 1 of 1

[SOLVED] After updating row result is 0

Posted: Wed Jul 06, 2005 7:34 am
by jurriemcflurrie
:oops: I should have seen that!

Anyways, thanks!




Hey, new here.. I have a problem wich I can't seem to solve. The result of the 'name' field in the following code is '0' afer updating. All the time. I have a similar problem with another code, that's why I have written this one. But the problem still exists.

here's the code:

Code: Select all

<?
	function updateArtist($id,$name,$genre,$description)
	{
	  $timestamp=time();
	  
	  $artist_update=mysql_query(&quote;
	    UPDATE artists
	    SET
	      artist_name='$name' AND
		  artist_genre='$genre' AND
		  artist_description='$description' AND
		  artist_timestamp='$timestamp'
	    WHERE
	      artist_id='$id'
	  &quote;)or die(&quote;&quote;.mysql_error());
	};

       if($_POST&#1111;action]==&quote;update&quote;)
	{
	  updateArtist($_POST&#1111;id],$_POST&#1111;name],$_POST&#1111;genre],$_POST&#1111;description]);
	}
?>
Here's the code that output the html

Code: Select all

<?
	$artist_get=mysql_query(&quote;
	  SELECT *
	  FROM artists
	  ORDER BY artist_name ASC
	&quote;)or die(&quote;&quote;.mysql_error());
	
	if(mysql_num_rows($artist_get)==0)
	{
	  echo&quote;No artists found!&quote;;
	}
	else
	{
	  while($artist_row=mysql_fetch_array($artist_get))
	  {
	    echo'<form action=&quote;&quote; method=&quote;post&quote; name=&quote;update_'.$artist_row&#1111;artist_id].'&quote; id=&quote;update_'.$artist_row&#1111;artist_id].'&quote;>
  			  <input name=&quote;name&quote; type=&quote;text&quote; id=&quote;name&quote; value=&quote;'.$artist_row&#1111;artist_name].'&quote;>
  			  <select name=&quote;genre&quote; id=&quote;genre&quote;>
    			  <option selected>Genre:</option>';
	  
        $genre_get=mysql_query(&quote;
	      SELECT *
		  FROM genres
		  ORDER BY
		    genre_name ASC
	    &quote;)or die(&quote;&quote;.mysql_error());
	    
	    while($genre_row=mysql_fetch_array($genre_get))
	    {
	      echo&quote;<option value=\&quote;$genre_row&#1111;genre_id]\&quote;&quote;;
		  
		  if($genre_row&#1111;genre_id]==$artist_row&#1111;artist_genre])
		  {
		    echo' selected';
		  }
		  
		  echo&quote;>$genre_row&#1111;genre_name]</option>&quote;;
	    };
	    
	    echo'</select>
  			  <input name=&quote;description&quote; type=&quote;text&quote; id=&quote;description&quote; value=&quote;'.$artist_row&#1111;artist_description].'&quote;>
  			  <input name=&quote;id&quote; type=&quote;hidden&quote; id=&quote;action&quote; value=&quote;'.$artist_row&#1111;artist_id].'&quote;>
  			  <input name=&quote;action&quote; type=&quote;hidden&quote; id=&quote;action&quote; value=&quote;update&quote;>
  			  <input type=&quote;submit&quote; value=&quote;Update&quote;>
			  </form>';
	  }
	}
?>
I hope I explained the problem well enough and if someone can help me or if someone has any tips for me I'll be glad to hear them!

Posted: Wed Jul 06, 2005 10:17 am
by shiznatix

Code: Select all

$artist_update=mysql_query("
UPDATE
  artists
SET
  artist_name='$name',
  artist_genre='$genre',
  artist_description='$description',
  artist_timestamp='$timestamp'
WHERE
  artist_id='$id'
")or die(mysql_error());
e='$name',
artist_genre='$genre',
artist_description='$description',
artist_timestamp='$timestamp'
WHERE
artist_id='$id'
")or die(mysql_error()); artist_description='$description',
artist_timestamp='$timestamp'
WHERE
artist_id='$id'
")or die(mysql_error());te;
UPDATE
artists
SET
artist_name='$name',
artist_genre='$genre',
artist_description='$description',
artist_timestamp='$timestamp'
WHERE
artist_id='$id'
")or die(mysql_error());
$artist_update=mysql_query("
UPDATE
artists
SET
artist_name='$name',
artist_genre='$genre',
artist_description='$description',
artist_timestamp='$timestamp'
WHERE
artist_id='$id'
")or die(mysql_error());
$artist_update=mysql_query("
UPDATE
artists
SET
artist_name='$name',
artist_genre='$genre',
artist_description='$description',
artist_timestamp='$timestamp'
WHERE
artist_id='$id'
")or die(mysql_error()); artist_genre='$genre',
artist_description='$description',
artist_timestamp='$timestamp'
WHERE
artist_id='$id'
")or die(mysql_error());artist_description='$description',
artist_timestamp='$timestamp'
WHERE
artist_id='$id'
&quote;)or die(mysql_error());ysql_query("
UPDATE
artists
SET
artist_name='$name',
artist_genre='$genre',
artist_description='$description',
artist_timestamp='$timestamp'
WHERE
artist_id='$id'
")or die(mysql_error());PDATE
artists
SET
artist_name='$name',
artist_genre='$genre',
artist_description='$description',
artist_timestamp='$timestamp'
WHERE
artist_id='$id'
&quote;)or die(mysql_error());'$description',
artist_timestamp='$timestamp'
WHERE
artist_id='$id'
")or die(mysql_error());[/php:1:
artist_name='$name',
artist_genre='$genre',
artist_description=
$artist_update=mysql_query("
UPDATE
artists
SET
artist_name='$name',
artist_genre='$genre',
artist_description='$description',
artist_timestamp='$timestamp'
WHERE
artist_id='$id'
")or die(mysql_error());sts
SET
artist_name='$name',
artist_genre='$genre',
artist_description='$description',
artist_timestamp='$timestamp'
WHERE
artist_id='$id'
")or die(mysql_eid='$id'
")or die(mysql_error());
$artist_update=mysql_query("
UPDATE
artists
SET
artist_name='$name',
artist_genre='$genre',
artist_description='$description',
artist_timestamp='$timestamp'
WHERE
artist_id='$id'
")or die(mysql_error());"
UPDATE
artists
SET
artist_name='$name',
artist_genre='$genre',
artist_description='$description',
artist_timestamp='$timestamp'
WHERE
artist_rtist_genre='$genre',
artist_description='$description',
artist_timestamp='$timestamp'
WHERE
artist_id='$id'
&quoe='$genre',
artist_description='$description',
artist_timestamp='$timestamp'
WHERE
artist_id='$id'
")or die(mysql_error());
$artist_update=mysql_query("
UPDATE
artists
SET
artist_name='$name',
artist_genre='$genre',
artist_description='$description',
artist_timestamp='$timestamp'
WHERE
artist_id='$id'
")or die(mysql_error());