Jump to content

[SOLVED] MySQL/php problem


RobertSubnet

Recommended Posts

Greetings all. For some reason I cannot get the bit of code below to work. What it is supposed to do is 1. read the current number of positive reviews and then increase the number of positive reviews by 1.

 

The $query62 is not updating the users table but I cannot find a fault in the coding.

 

The MySQL field type is an int(7) unsigned default '0' not null

 

I have the error reporting set to E_ALL and PHP is not complaining.

 

Just for grins, I had php display the values of the following variables:

 

the value of row is:

the value of fixed pos is:

the value of increase pos is: 1

 

So $increase_pos has a value. I don't understand why it is not updating my users table with that value.

 

Any suggestions would be much appreciated.

Thanks!

 

 

 

Switch ($review) {

 

  case "positive":

 

  $_one = 1;

 

  /*Get the current number of

  positive (pos) reviews and increase

  by one. */

 

  $query_pos = "Select positive_sales from users where login_name = '$seller_name'";

 

  $result_pos = mysql_query($query_pos);

 

  $row = mysql_fetch_assoc($result_pos);

 

  $fixed_pos = $row['positive_sales'];

 

  $increase_pos = ($fixed_pos + $_one);

 

  $query62 = "update users set positive_sales = '$increase_pos' where login_name = '$seller_name'";

 

  $result62 = mysql_query($query62);

 

 

  break;

Link to comment
https://forums.phpfreaks.com/topic/126238-solved-mysqlphp-problem/
Share on other sites

Barand:

 

Thanks! I rewrote the query the way you suggested and it still did not work. I then checked the value of $seller_name and it came up as a MySQL Resource ID. After running the $seller_name query through mysql_fetch_assoc, everything else worked the way it should.

 

Thanks again for your help!

 

~Robert

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.