I am a long time php coder, that needs to convert a script to Perl.
Here is the code in PHP
[tab]$store_list_name = $prod[10];
[tab]$category = $prod[11];
[tab]$sub_category = $prod[12];
[tab]$searchfor = $store_list_name . "->" . $category . "->" . $sub_category;
[tab]$getcat = mysql_query("SELECT * FROM categories WHERE (overstock_id LIKE '%|".addslashes($searchfor)."|%');",$link);
[tab]while ($p_row =mysql_fetch_array ($getcat) ) {
[tab]$cat_name = stripslashes($p_row[cat_name]);
[tab]$cat_id = $p_row[cat_id];
[tab]$sub_of = $p_row[sub_of];
[tab]}
Here is what I have in PERL:
[tab]my $searchfor = $store_list_name . "->" . $category . "->" . $sub_category;
[tab]my $search_by = $dbh->quote($searchfor);
[tab]my $query = "SELECT * FROM categories WHERE overstock_id %|".$searchfor."|%";
[tab]my $dth = $dbh->prepare($query);
[tab]$dth->execute();
[tab]my $ref;
[tab]while ($ref = $dth->fetchrow_hashref())
[tab]{
[tab]my $master_cat = $ref->{cat_id};
[tab]my $sub_cat = $ref->{sub_of};
[tab]}
The problem I am running into is, I get this error:
DBD::mysql::st execute failed: 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 '|Tools->Professional Grade Tools->Tool Sets|%' at line 1 at ./test.pl line 57, <CSV> line 585.
My first % is going bye bye.... Can some one help?
Here is the code in PHP
[tab]$store_list_name = $prod[10];
[tab]$category = $prod[11];
[tab]$sub_category = $prod[12];
[tab]$searchfor = $store_list_name . "->" . $category . "->" . $sub_category;
[tab]$getcat = mysql_query("SELECT * FROM categories WHERE (overstock_id LIKE '%|".addslashes($searchfor)."|%');",$link);
[tab]while ($p_row =mysql_fetch_array ($getcat) ) {
[tab]$cat_name = stripslashes($p_row[cat_name]);
[tab]$cat_id = $p_row[cat_id];
[tab]$sub_of = $p_row[sub_of];
[tab]}
Here is what I have in PERL:
[tab]my $searchfor = $store_list_name . "->" . $category . "->" . $sub_category;
[tab]my $search_by = $dbh->quote($searchfor);
[tab]my $query = "SELECT * FROM categories WHERE overstock_id %|".$searchfor."|%";
[tab]my $dth = $dbh->prepare($query);
[tab]$dth->execute();
[tab]my $ref;
[tab]while ($ref = $dth->fetchrow_hashref())
[tab]{
[tab]my $master_cat = $ref->{cat_id};
[tab]my $sub_cat = $ref->{sub_of};
[tab]}
The problem I am running into is, I get this error:
DBD::mysql::st execute failed: 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 '|Tools->Professional Grade Tools->Tool Sets|%' at line 1 at ./test.pl line 57, <CSV> line 585.
My first % is going bye bye.... Can some one help?