I am trying to install http://prosper202.com (self hosted script on Azure )
Here is what i have done.
Created a Azure Website with MySQL Database.
Configured Database login Credentials.
Now i am getting this error
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 'AND 202_summary_overview.click_time < AND landing_page_id=0 ' at
line 12
SELECT 202_aff_campaigns.aff_campaign_id
, aff_campaign_name
, aff_campaign_payout
, aff_network_name
FROM 202_summary_overview
LEFT JOIN 202_aff_campaigns USING (aff_campaign_id)
LEFT JOIN 202_aff_networks USING (aff_network_id)
WHERE 202_aff_networks.user_id = '1'
AND 202_aff_networks.aff_network_deleted = 0
AND 202_aff_campaigns.aff_campaign_deleted = 0
AND 202_summary_overview.click_time >=
AND 202_summary_overview.click_time <
AND landing_page_id = 0
GROUP BY aff_campaign_id
ORDER BY 202_aff_networks.aff_network_name ASC
, 202_aff_campaigns.aff_campaign_name ASC
Warning: Division by zero in C:\DWASFiles\Sites\click\VirtualDirectory0\site\wwwroot\202-config\functions-tracking202.php on line 1048 SELECT * FROM 202_sort_keywords LEFT JOIN 202_keywords ON (202_sort_keywords.keyword_id = 202_keywords.keyword_id) WHERE 202_sort_keywords.user_id='1' ORDER BY 202_sort_keywords.sort_keyword_clicks DESC LIMIT
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 '' at line 1
I have no clue to fix this problem.
Can i use Azure SQL in place os MySQL , without any modification in script?
Further http://click.azurewebsites.net/tracking202/setup/aff_campaigns.php
Gives me these Errors
INSERT INTO `202_aff_campaigns` SET`aff_network_id`='1', `user_id`='1', `aff_campaign_name`='eDates', `aff_campaign_url`='http://googl.com', `aff_campaign_url_2`='', `aff_campaign_url_3`='', `aff_campaign_url_4`='', `aff_campaign_url_5`='', `aff_campaign_rotate`='0', `aff_campaign_payout`='0.9', `aff_campaign_cloaking`='1', `aff_campaign_time`='1355885344'
Field 'aff_campaign_id_public' doesn't have a default value
This same script hosted here http://prosper202.com/ is working of thousands on server. But its not working on Azure MySQL.
Some more details
http://i.stack.imgur.com/SfhPs.png
you have no value supplied on which the column will be compare to,
SELECT ....
FROM ....
WHERE ....
AND 202_aff_campaigns.aff_campaign_deleted = 0
AND 202_summary_overview.click_time >= // << error on this line
AND 202_summary_overview.click_time < // << also here
AND landing_page_id = 0
You need to add a record into user_pref for the new user...so i just copied the first user record into second and just update the user_id accordingly.
CREATE TEMPORARY TABLE tmp SELECT * FROM 202_users_pref WHERE user_id = 1;
UPDATE tmp SET user_id=2 WHERE user_id = 1;
INSERT INTO 202_users_pref SELECT * FROM tmp WHERE user_id = 2;
DROP TABLE tmp;
Hope this helps someone
Related
Why do I get this error?
The SQL works fine when I run it in phpMyAdmin.
SQLSTATE[42000]: Syntax error or access violation: 1064 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 '' at line 1 (SQL: select id from users where active = true and birthyear != 0000 and not exists (select id from agestats where users.id = agestats.user_id and agestats.year = 2020-01-13)
SQL:
select id
from users
where active = true
and birthyear != 0000
and not exists (
select 1
from agestats
where users.id = agestats.user_id
and agestats.year = 2020
)
And the Laravel code:
$membersToInsert = DB::select(DB::raw(
'select id
from users
where active = true
and birthyear != 0000
and not exists (
select id
from agestats
where users.id = agestats.user_id
and agestats.year = ' . date('Y-m-d')
));
date('Y-m-d') will give you current date like 2020-01-13 so to get just 2020 then use date('Y'). I hope this helps your situation
Due to many limitations, I'm only able to use vanilla PHP. The current API is plain and simple, it has two tables, one is for stats, the other includes the records.
First, stats table will be fetched:
$tempStatsName = $this->getRandomIndexString();
$sql = "CREATE TEMPORARY TABLE IF NOT EXISTS " . $tempStatsName . " AS SELECT COUNT(*) AS total_visits, series_id FROM my_stats_table d2 WHERE d2.stats_type = 1 GROUP BY series_id;";
$this->conn->exec($sql);
Then, an index will be added
$sql = "ALTER TABLE `" . $tempStatsName . "` ADD INDEX `" . $this->getRandomIndexString() . "` (`series_id`);";
$this->conn->exec($sql);
getRandomIndexString is a function that generates a unique random string.
return substr(str_shuffle(MD5(microtime())), 0, 10)
Finally, the last query will be executed:
SELECT database_series.id, database_stats.total_visits,(SELECT COUNT(*) FROM myreviewstable d_reviews WHERE d_reviews.media_id = database_series.id AND d_reviews.review_media_type = 0) series_reviews_count, (SELECT TRUNCATE(AVG(d_reviews2.review_rating_value), 1) FROM myreviewstable d_reviews2 WHERE d_reviews2.media_id = database_series.id AND d_reviews2.review_media_type = 0) series_reviews_value, database_series.series_title, database_series.series_description, database_series.series_thumbnail, (SELECT COUNT(*) FROM myepisodestable d_episodes WHERE d_episodes.episode_series = database_series.id) series_episodes_count FROM myrecordstable database_series LEFT JOIN " . $tempStatsName . " database_stats ON (database_stats.series_id = database_series.id)
Exception:
Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 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 '189e087f9e0ce79e31b4 AS SELECT COUNT(*)
Another example:
1064 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 '2332e22834 database_stats ON (database_stats.series_id = database_series.id) WHE'
This exception only happens when I request a call to the API 3x times in a row (in less than 2s due to lazy-scroll methods being called).
If I wait a few seconds and then try scrolling, the API will be called and no exception will be shown.
I'm unable to know why the exception happens, are there any duplicated temp tables? I'm pretty sure it's not an issue with the max_heap_size, the records are less than 100.
The important parts of the database are the stats & records tables, other tables are not important and didn't cause any issues.
my_stats_table:
id stats_type series_id created_at created_at_text
myrecordstable:
id series_title created_at
Basically, the three queries are executed in the same connection and are included in a function called getSeries(). It executes the first, which creates the temp table, after that alters the table, finally, it executes the code which fetches the records of myrecordstable.
I have an SQL statement which runs perfectly when used on phpmyadmin,
$q1 = " SET #pos = 0; UPDATE `songs` SET `tweek` = ( #pos:= #pos+1) WHERE `approved` = 1 ORDER BY votes DESC ";
my connection is fine, every other thing is fine but I keep getting an error when I use it in my php code.
mysql_query($q1, $link) or die(mysql_error());
Error:
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 'UPDATE `songs` SET `tweek` = 1 WHERE `approved` = 1 ORDER BY
votes DESC' at line 1
Please help.
SET and UPDATE are two queries and you must split it into two different calls of mysql_query
public function delete($group_id)
{
$this->db->where('t1.*, t2.*, t3.*, t4.*, t6.*, COUNT(t5.id) AS total_students')
->join('groups_days AS t6', 't1.group_id = t6.group_id')
->join('groups_members AS t5', 't1.group_id = t5.group_id')
->group_by('t1.group_id')
->delete("groups AS t1")
->result();
}
Error Number: 1064
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 'AS `t1` WHERE t1., t2., t3., t4., t6.*, COUNT(t5.id) AS total_students' at line 1
DELETE FROM `groups` AS `t1` WHERE t1., t2., t3., t4., t6.*, COUNT(t5.id) AS total_students
Filename: D:/www/domains/uzdev/taraqqiyot/application/models/Group_model.php
My delete not working and showing above error. What is wrong here
According to this link you can't do delete with join with CodeIgniter Active Records:
link
Another option is using several queries as many as number of tables:
$this->db->delete('groups', array('group_id'=>$group_id));
$this->db->delete('groups_days', array('group_id'=>$group_id));
$this->db->delete('groups_members', array('group_id'=>$group_id));
I have syntax error with my code
$insert = #mysql_query("INSERT INTO topics (t_title, t_desc, t_pic, t_link, t_date,cat_id)
SELECT '$t_title','$t_desc','$t_pic','$t_link','$t_date','$cat_id'
WHERE NOT EXISTS (SELECT t_link
FROM topics
WHERE t_link = $t_link
)
")or die(mysql_error());
This returns an error :
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 NOT EXISTS (SELECT t_link FROM topics WHERE t_link = 'showthread.php?t=120' at line 3
I thought that the problem is with t_link = $t_link
But when i replaced it with normal value , the problem persists.
Any help ?
You missed the FROM on first SELECT
SELECT '$t_title','$t_desc','$t_pic','$t_link','$t_date','$cat_id'
# MISSED HERE FROM ???
WHERE NOT EXISTS
Here solution for FROM CLAUSE, please, check as solution chumkiu's answer, not mine.
create table a ( i int);
insert into a (i )
select 1
from dual
where 1=2;
insert into a (i )
select 3
from dual
where 1=1;
Results
If t_link is has a unique index in the table, you can do:
$insert = #mysql_query("INSERT IGNORE INTO topics (t_title, t_desc, t_pic, t_link, t_date,cat_id)
VALUES ('$t_title','$t_desc','$t_pic','$t_link','$t_date','$cat_id');
The IGNORE keyword tells it to do nothing if the insert would duplicate a unique key constraint.