Reputation: 2589
I am trying to update a table from inside my code. I am modding an preexisting code in order to upload pdf document instead jpg. The auctions table has this features
mysql> describe webid_auctions;
+----------------+-------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------------+------+-----+---------+----------------+
| id | int(32) | NO | PRI | NULL | auto_increment |
...
| pict_url | tinytext | YES | | NULL | |
and the filestore table has this
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| auction_id | int(11) | NO | | NULL | |
| user_id | int(11) | NO | | NULL | |
| user_action | varchar(50) | NO | | NULL | |
| filename | varchar(255) | NO | | NULL | |
| mimetype | varchar(50) | NO | | NULL | |
| url | varchar(255) | YES | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
the code i am trying to execute is this:
foreach ($UPLOADED_PICTURES as $k => $v)
{
$system->move_file($upload_path . session_id() . '/' . $v, $upload_path . $auction_id . '/' . $v);
chmod($upload_path . $auction_id . '/' . $v, 0777);
$furl = $upload_path . $auction_id . '/' . $v;
$uid = $user->user_data['id'];
/*first query */
$query = "INSERT into " .$DBPrefix. "filestore SET
auction_id = '$auction_id',
user_id = '$uid',
user_action = 'hire',
filename = '$v',
url = '$furl'";
$res = mysql_query($query);
$system->check_mysql($res, $query, __LINE__, __FILE__);
/*Second query */
$query = "UPDATE " .$DBPrefix. "auctions SET
pict_url = '$v',
WHERE id = '$auction_id'";
$res = mysql_query($query);
$system->check_mysql($res, $query, __LINE__, __FILE__);
}
The first query is performed with no problem. When the code execute the second query, php tells me
ErrorArray ( [0] => Unknown error type: [2] fopen(/var/www/WeBid//logs/requests.log):
failed to open stream: Permission denied on /var/www/WeBid/includes/functions_user.php
line 74 [1] => Database access error. Please contact the site administrator. UPDATE
webid_auctions SET pict_url = 'financialfoundamentals.pdf', WHERE id = '18' You have an
error in your SQL syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near 'WHERE id = '18'' at line 3 page:/var/www/WeBid/sell.php
line:235 [2] => Unknown error type: [2] fopen(/var/www/WeBid/logs/error.log): failed to
open stream: Permission denied on /var/www/WeBid/includes/errors.inc.php line 23 )
I am not en expert neither of php nor of mysql, but the csm act into the databse with a unique user with all permissions granted. I have checked the query from inside mysql and all work fine, so I can't understand where the error could came from. Who can have an idea what is happening?
Upvotes: 0
Views: 99
Reputation: 1929
There's an extra comma ,
after pict_url = '$v',
. Removing it should fix the problem.
Upvotes: 1