I am attempting to customize my PHP code to add the product ID to the link stored in the database (which is 'prodLink'). The table is 'affiliSt_products1' and the stored variable we want to add to the end of this link is 'merchantProdID' The relevant code: // get the category listings $sql = sprintf("SELECT * FROM affiliSt_products1 WHERE prodDB = %d AND dbProdID = %s", quote_smart($_GET['proddb']), quote_smart($_GET['1'])); $getLinks = mysql_query($sql, $databaseConnect) or die(mysql_error()); // $merchantLink = mysql_fetch_assoc($getLinks); $merchantLink = mysql_fetch_assoc($getLinks); $link = $merchantLink['prodLink']; Code (markup): TIA
//write query, run query & get row $sql = "SELECT * FROM affiliSt_products1 WHERE prodDB = %d AND dbProdID = %s;"; $result = mysql_query($sql); $array = mysql_fetch_array($result); //get prodLink out of row $r_prodLink = $array[0]; // array id for prodLink in here //add merchantProdID to link $r_prodLink .= $merchantProdID; //store new link $q = "INSERT INTO affiliSt_products1 (prodLink) VALUES ('". $r_prodLink ."');"; mysql_query($q); Code (markup): Is this something you meant?
Something like that I tried it and got this: "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource" Then I tried modifying some things and got similar warnings or syntax errors. (I know very little about PHP) But what I was thinking was that the original code already seems to be making the proper sql call. I thought maybe we could just amend $getLinks or $link to add that other variable ? Like: $link = $merchantLink['prodLink'.'$merchantProdID']; Code (markup): But this just produces a page that loops continuously for whatever reason. I tried to see what the value of $merchantProdID (using print) but it comes up empty, so maybe we do need another db call for it. I also tried using str_replace in place of above, but got this: PHP Warning: Wrong parameter count for str_replace()
Maybe it would be easier to bypass whatever is going on with that page and just write up our own PHP code to produce these links I need? The code above was from the file, "go.php" and what would be a "Buy Now" or "Add to Cart" button link looks like this: /go.php?proddb=1&l=6 Would it be easier to match up the above product (6) (which is in same table as 'dbProdID' and 'proddb') to its matching 'prodLink' plus add 'merchantProdID' to this and then send them to that page ? /prodLinkmerchantProdID PS: This link will be going to another URL... so we can break from the code from our script at this point anyway.