-
Posts
3,584 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JonnoTheDev
-
[SOLVED] how to hide <br /> tag in textarea?
JonnoTheDev replied to irkevin's topic in PHP Coding Help
Dont use the nl2br() function when placing the text back into the text area. Only use this function when displaying the text on the screen within the HTML. The text should remain formatted in the text area. -
Place the CSS inside the P tag as a style attribute and not in the stylesheet
-
There is no error here. This is the create table command
-
Image UPDATE script not updating properly.
JonnoTheDev replied to portalpie's topic in PHP Coding Help
Use a loop for the number of items then you dont need any code duplication: $images = array(1,2,3,4); foreach($images as $imageNum) { $imagename = $_FILES['new_image'.$imageNum]['name']; } Finish the rest off. -
Dont think this is possible. The exit() and die() functions are not designed for this. You can either print your html to the screen then exit or die, or implement a custom error handler that displays an error page.
-
Ignore comma in csv file before import to mysql database
JonnoTheDev replied to candice's topic in PHP Coding Help
Change the CSV to use a pipe delimeter | instead of a comma if some of the fields are text. This will make life a lot easier. -
You will require what is called a recursive function that starts with the top level parentId (assuming it is 0) and then changes for each database row. You need to build a multi dimensional array from the function.
-
This is incorrect if($_GET['_a'] == 'viewProd') { $body = new XTemplate ("global".CC_DS."product.tpl"); } else if(isset($_GET['_a'])) { $body = new XTemplate ("global".CC_DS."index.tpl"); } else { $body = new XTemplate ("global".CC_DS."home.tpl"); } When $_GET['_a'] == 'viewProd' you are setting $body to a new instance of the index teplate using isset($_GET['_a']) because _a is set and set to 'viewProd'. You may need to add a new url param to set the index template like: if($_GET['_a'] == 'viewProd') { $body = new XTemplate ("global".CC_DS."product.tpl"); } else if($_GET['_a'] == 'index') { $body = new XTemplate ("global".CC_DS."index.tpl"); } else { $body = new XTemplate ("global".CC_DS."home.tpl"); }
-
This will be difficult for you if you dont know php. Im guessing its the following param that defines what code is run and applied to the template: _a=viewProd So to change the product detail template you would be looking at something like if($_GET['_a'] == 'viewProd') { $body = new XTemplate ("global".CC_DS."product.tpl"); } else { // load the default template } There will probably be more in the code that you will have to modify.
-
There are many Paypal options. They have a shopping cart that is similar to basic buy now only you can add many items and include things like shipping. You can also use IPN (instant payment notification) if your website needs to be informed of a successful or failed transaction lets say to process an order. This is the best option if you want users to be redirected to the Paypal screens but process information on your site at the same time. If you want to users to remain on your site where they will enter credit card information and have it processed you will need Website Payments Pro. You will need to get an SSL certificate to do this. This is my preferred option.
-
This is the index template being called (instantiated): $body = new XTemplate ("global".CC_DS."index.tpl"); This is the cart template being called (instantiated): $body = new XTemplate("global".CC_DS."cart.tpl"); This doesnt make sense: Every time you see $body->assign() or $variable->assign() this is data being passed into the template. There are just far too many includes in the php code to see what is going on. The data within these includes will more than likely change when URL params are used in each page call therefore changing the layout of the template. Im not sure what you need help for? Are you redesigning the site? If this is Cubecart then surely they must have a document structure definition of their site templates or a user forum.
-
The templates are defined at the top of each file as far as I can see. Looks a similar mechanism to the Smarty template engine. $body = new XTemplate ("global".CC_DS."index.tpl"); $body = new XTemplate("global".CC_DS."cart.tpl"); $box_content = new XTemplate("boxes".CC_DS."shoppingCart.tpl"); Find out where the CC_DS constant is defined to get the full template path
-
What is the most efficient way to copy image from external site
JonnoTheDev replied to stevesimo's topic in PHP Coding Help
try WGET -
Make sure that your queries are optimised using EXPLAIN http://dev.mysql.com/doc/refman/5.0/en/explain.html
-
Incorrect, looking at your file the values will instantly change the moment that the form is submitted. What you need to do is store the current values of $parent & $child into hidden fields within the form so you can then test the $POST['parent'] & $POST['child']. Once you check the values you should then reload the page so new values are generated so something like: // form posted if($_POST['submit'] == 'submit') { if(($_POST['child'] == "Abby") || ($_POST['child'] == "Will" && $_POST['parent'] == Mark) || ($_POST['parent'] == Missy)) { echo "That is correct"; // display a link to repload the page here } } else { $parents = array("Nick","Kristin","Mark","Missy"); $children = array("Peyton","Greddy","Abby","Will"); $random_parents = array_rand($parents); $random_children = array_rand($children); $parent = $parents[$random_parents]; $child = $children[$random_children]; // display the form here ?> <form method="post" action=""> <input type="hidden" name="parent" value="<?php echo $parent; ?>" /> <input type="hidden" name="child" value="<?php echo $child; ?>" /> <?php } You should be able to complete the rest.
-
You are better defining the checkbox name as an array so no loop is required: <input type="checkbox" name="zipnum[]" value="1" /> <input type="checkbox" name="zipnum[]" value="2" /> <input type="checkbox" name="zipnum[]" value="3" /> and so on Then you can just view the values in the post array print_r($_POST['zipnum']);
-
Are you aware that your $parent & $child values will change after the form is submitted
-
echo "<xmp>".$output."</xmp>";
-
When writing to the file get your data in an array so: $items[] = "item 1"; $items[] = "item 2"; $items[] = "item 3"; The you can use implode() to properly write the separated items in a line: $line = implode(":", $items); echo $line; This will print item 1:item 2:item 3 When retrieving the data you will need to explode() it back into an array so: $items = explode(":", $row); print_r($items); This will produce [0] => item1, [1] => item 2, [2] => item 3 and will make it much easier to display the data
-
No, you can get the agent - but be warned it can easily be spoofed! getenv("HTTP_USER_AGENT"); I use the following to stop SE spiders from starting sessions. function isSpider($userAgent) { if(stristr($userAgent, "Googlebot") || /* Google */ stristr($userAgent, "Slurp") || /* Inktomi/Y! */ stristr($userAgent, "MSNBOT") || /* MSN */ stristr($userAgent, "teoma") || /* Teoma */ stristr($userAgent, "ia_archiver") || /* Alexa */ stristr($userAgent, "Scooter") || /* Altavista */ stristr($userAgent, "Mercator") || /* Altavista */ stristr($userAgent, "FAST") || /* AllTheWeb */ stristr($userAgent, "MantraAgent") || /* LookSmart */ stristr($userAgent, "Lycos") || /* Lycos */ stristr($userAgent, "ZyBorg")) { /* WISEnut */ return true; } return false; } if(isSpider(getenv("HTTP_USER_AGENT"))) { // redirect bots } The agent will still be in the server access logs however
-
Are you talking about you server access logs or logs that you are creating? Do you want spiders blocked from your site? If so you can exclude them in a robots.txt file
-
You need to add a WHERE clause to the SQL based on the users selection
-
Image UPDATE script not updating properly.
JonnoTheDev replied to portalpie's topic in PHP Coding Help
No, you simply need to check that a new image was selected to overwrite the original. // a new image has been entered if(strlen($_FILES['new_image']['name'])) { // delete the original and replace with this image } else { // keep the existing image - do not overwrite the existing database record }