Jump to content

[SOLVED] i am 1 step away from being done on a 3 year project please help php code


scbookz

Recommended Posts

here is my code

----------------------------

<?php

$oscfile = file_get_contents("http://www1.com/osc/osc/osc/catalog/product_info.php?products_id");

$osc = (get_oscdoc_title($oscfile));

 

 

//function

function get_oscdoc_title($oscfile){

$osctag = preg_match_all('/$products_description/', $oscfile, $oscmatches, PREG_PATTERN_ORDER);

return($oscmatches[1][0]);}

 

 

$test = "$oscmatches";

 

 

$file = file_get_contents("http://www2.com/IsbnSearch.aspx?isbn={$test}");

$x = (get_doc_title($file));

 

echo preg_replace('/^Book -/','(10 digit isbn above) -',$x);

 

// retrieve page title

function get_doc_title($file){

    $h1tags = preg_match_all('/<title>(.*)<\/title>/', $file, $matches, PREG_PATTERN_ORDER);

return($matches[1][0]);}

 

?>

------------------------

here is my error

----------------------------

www2.com - ISBN format error!

-----------------------------------------------------

this error is because a numeric value is not being placed at the end of the  url/number

but it is placing either a string or a non entity

-----------------------------------------------------

i need a number value  for product _description but it is not grabbing this from the .php file

that is a database descriptor and the  file i am trying to grab has code  like this on that particular line

------------------

 

line 110

 

$product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

 

 

      line 123  <p><?php echo stripslashes($product_info['products_description']); ?></p>

------------------

 

so in summary i need product_description but as a number and not as a string

but i am not sure  product description is a variable from this mysql database and possible java script

Link to comment
Share on other sites

what i have is an osc  php mysql setup

 

where i am grabbing  from an html  page and inserting into the products_description

 

in order for me to  work this right i have to use the  database upload file they give for my  bulk uploads so i have to use this setup because my bulk upload csv wont take much php

 

it does take <iframe> in my cell  csv upload

 

my excel upload will  take <iframe> and i include my .php file and then it post the products_description perfectly

but the variable i need is the  products_descriptionvariable

this works  good for 1 page but that variable i need  is the kicker

 

it comes from a  html page but has  some funky code i dont know i wonder if the description is even readable by php as i have it or do i need to  take java code and convert it to php? i do not know java at all  so i wonder if the  description is even a variable that  php  can read

Link to comment
Share on other sites

if i  put a  number in the variable then it works fine but that is a static umber i need the number to change according to the  product description

 

ww1 is an internal built in  .php  from oscommerce

 

and  ww2 is an eternal from oscommerce

 

everything works until i try to add the  "product_description"

if i add a number it is fine but as i say  it will display the same out put for each item i need this variable

to make it right

Link to comment
Share on other sites

trust me the product_description  value i have in my database is a number

 

i am  doing things a little reverse

i did not want to mess with osc code so i use easypopulate

 

but my description value is an isbn and not a description

and then i am reverse engineering i am too far into it to change now

 

i need that  value a number to be showing on php as a  single  number and i think youare right  it is an array right now

can i break my array apart? into numbers

Link to comment
Share on other sites

well

that should be easy enough 

 

give this a shot:

<?php

$oscfile = file_get_contents("http://www1.com/osc/osc/osc/catalog/product_info.php?products_id");
$osc = (get_oscdoc_title($oscfile));


//function
function get_oscdoc_title($oscfile){
   $osctag = preg_match_all('/$products_description/', $oscfile, $oscmatches, PREG_PATTERN_ORDER);
   return($oscmatches[1]);}

   
   foreach ($osctag as $match) {
	$file = file_get_contents("http://www2.com/IsbnSearch.aspx?isbn={$match}");
	$x = (get_doc_title($file));
	echo preg_replace('/^Book -/','(10 digit isbn above) -',$x);
   }




// retrieve page title
function get_doc_title($file){
    $h1tags = preg_match_all('/<title>(.*)<\/title>/', $file, $matches, PREG_PATTERN_ORDER);
   return($matches[1][0]);}
   

Link to comment
Share on other sites

/osc/osc/osc/catalog/product_info.php?products_id

 

doesn't return any products

 

do you have access to http://www1.com??? (as in can you edit the php files on it?)

 

 

because what you need to do is quite simple

 

 

connect to database, extract ISBN

THEN run your search and regex on www2 for EACH ISBN received...

 

it's really quite simple.

 

//edit

 

OHHHHHHHHHHH I see what you're doing... give me 10 secs

Link to comment
Share on other sites

ww1 is in my server i have total control over it i have built everything from scratch

 

3 or 4 times now i  am on this last leg

 

one more code and i am done with adsense and everything then i am on my way to riches lol

 

-----------------

 

well after this i will need to figure out  google  base  upload of xml

 

shouldnt be too hard though

Link to comment
Share on other sites

can you just turn this  return($oscmatches[1]);}

 

into a number and i am done

 

all i need is one part of the array to convert it to a number and i am done  except  for whether i use  "" or ' '

 

or pregmatch  or pregmatch all

Link to comment
Share on other sites

in a quick summary i am using  isbn as my description upload from my excel file

whereas osc uses  many variables from database

 

i do not know  mysql terminology so i try to avoid it

 

and then i have a simple script

 

instead of grabbing from a database i am grabbing from a  .php generated  page

Link to comment
Share on other sites

I#m crap with regex

 

 

write me an expression to capture the ISBN:

 

<td class="pageHeading" valign="top">0324183313<br><span class="smallText">[1217]</span></td>

 

ISBN is 10 or 13 digits, the last one CAN be an X

 

 

also.. what's the excel file for?

Link to comment
Share on other sites

is this a possible answer?

 

As in Perl, you can access a value from the array inside double quotes. However, with PHP you'll need to enclose your array between curly braces.

 

Example #4 Accessing an array inside double quotes

<?php

 

$foo = array('bar' => 'baz');

echo "Hello {$foo['bar']}!"; // Hello baz!

 

?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.