Jump to content

bullbreed

Members
  • Posts

    110
  • Joined

  • Last visited

About bullbreed

  • Birthday 09/19/1973

Profile Information

  • Gender
    Male
  • Location
    Manchester

bullbreed's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi everyone I have a bit if an issue with some PHP i;ve been playing with. The following code is working fine to delete data from the database if (isset($_GET['p'])){ $namecheck = mysql_query("SELECT `name` FROM `store` WHERE `name` = '".$_GET["p"]." '"); $count = mysql_num_rows($namecheck); if ($count !== 0){ if ($_GET['sure'] === '1'){ mysql_query("DELETE FROM `store` WHERE `name` = '".$_GET["p"]."' LIMIT 1"); }else{ echo '<font size="2" color="#ff0000">Are you sure you want to delete this retailer? <a href="deleteretailer.php?p='.$_GET['p'].'&sure=1">Yes</a> or <a href="deleteretailer.php">No</a></font>'; } } } However if the name contains a & character such as A & B Engineering the echo message doesn't show and I can't delete the data from the database. Is the & character causing an issue as it only seems to affect those names containing it. Thanks B
  2. If you leave the insert set to php you only have to click it . Once you set it it stays set unless you change it. I dont know if there is a hotkey for it You could learn to type fast
  3. Yes In dreamweaver click on Window and make sure your INSERT menu is ticked. On your insert menu make sure that you select the php tab and you will see a button <? to click to create <?php ?> tags
  4. I'm sorry but im very new to php and dont understand :-\ Could you explain a little more please
  5. Hi Guys I have a page on my website that enables a customer to select a product, choose a colour and a size, create some custom text then send that data to my cart.php page. I'm not sure if I am doing this the correct way and haven't done a cart before. This form collects the data then posts it to the cart.php page <form action="cart.php" method="POST"> <input type="hidden" name="category" id="category" value="<?php echo $_GET['cid']; ?>" /> <input type="hidden" name="name" id="name" value="<?php echo $_GET['nid']; ?>" /> <input type="hidden" name="colour" id="colour" value="<?php echo $_GET['colid']; ?>" /> <input type="hidden" name="input" id="input" value="<?php echo $_POST['input']; ?>" /> <input type="hidden" name="fontselect" id="fontselect" value="<?php echo $_POST['fontselect']; ?>" /> <input type="hidden" name="sizeselect" id="sizeselect" value="<?php echo $_POST['sizeselect']; ?>" /> <div class="textinputgo"><input name="cart" type="submit" id="cart" value="Add to Cart" /></div> </form> This is the cart.php page which displays the product selections on the page; ( I have used tables for now but will change these to divs.) <h1>Shopping Cart</h1> <?php $submit = ($_POST['cart']); if (!isset($submit)){ echo 'Your cart is empty'; }else { //Form data $category = ($_POST['category']); $name = ($_POST['name']); $colour = ($_POST['colour']); $text = ($_POST['input']); $font = ($_POST['fontselect']); $size = ($_POST['sizeselect']); if (isset($submit)){ // This page displays the contents of the shopping cart. // Create a table and a form. echo '<table border="1" width="90%" cellspacing="3" cellpadding="3" align="left"> <tr> <td align="left" width="15%"><b>Category</b></td> <td align="left" width="15%"><b>Name</b></td> <td align="left" width="15%"><b>Colour</b></td> <td align="left" width="15%"><b>Text</b></td> <td align="left" width="10%"><b>Font</b></td> <td align="left" width="15%"><b>Size</b></td> </tr> '; echo '<tr>'; echo '<td align="left">' . $category . '</td>'; echo '<td align="left">' . $name . '</td>'; echo '<td align="left">' . $colour . '</td>'; echo '<td align="left">' . $text . '</td>'; echo '<td align="left">' . $font . '</td>'; echo '<td align="left">' . $size . '</td>'; echo '</tr>'; echo '</table>'; } } ?> My questions are; 1. How do I add the facility to increse the quantity of the products on the cart.php page? 2. If I go to another page then click on cart again the cart is empty so how do I keep the info in the cart? I'm assuming some sort of session but dont know how to do these. Thanks guyz
  6. Thanks for that. Please be aware that I have only been doing PHP for a couple of months now and at 36 yrs old its a bit like teaching an old dog new tricks. lol. Remember I come from a time of Commodore 64 and BBC Master 128. I changed the code to this; <?php $sql = "SELECT * FROM `products` WHERE `prod_name` = '".$_GET['nid']."' limit 1 "; $query = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($query) > 0) { while ($row = mysql_fetch_assoc($query)){ $sizes = $row['prod_sizes']; $sizes = unserialize($sizes); $itemcount = count($sizes); } } ?> <label>Select a Size</label> <div class="textinput"> <select name="sizeselect"> <?php for ($i=0;$i<$itemcount;$i++) { ?> <option><?php echo $sizes[$i]; ?></option> <?php } ?> </select> So if I understand correctly, the issue was because the For (){} loop was performing a loop for each size option as an individual, hence individual menu form fields. But because I put the for(){} loop around only the <option>...</option> code this placed the data in one meny field. Thanks for your help.
  7. any ideas guyz and girlz For each size in the database I get an individual menu field so if there are 5 sizws I get 5 menu drop doen boxes
  8. How do I get them to show in one menu drop down. I remember reading somewhere about array-unique. Would this be used in the script. Im quite lost on this one.
  9. Ah yes, thank you. I set the size of the varchar to 10 (duh) he result is a little strange though now I changes it because I now get each size displayed in its own menu dropdown so if I have sizes S-M-L-XL they display in their individual drop down menus instead of all being in 1 menu drop down
  10. I have some serializes data in the db that holds the sizes of a product and i'm trying to unserialize it and show it in a menu form field but im having a few problems. Heres the code <?php $sql = "SELECT * FROM `products` WHERE `prod_name` = '".$_GET['nid']."' limit 1 "; $query = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($query) > 0) { while ($row = mysql_fetch_assoc($query)){ $sizes = $row['prod_sizes']; $sizes = stripslashes($sizes); $sizes = unserialize($sizes); $itemcount = count($sizes); for ($i=0;$i<$itemcount;$i++) { ?> <div class="contwraps"> <label>Select a size</label> <div class="textinput"> <select name="sizeselect"> <option><?php echo $sizes[$i]; ?></option> </select> </div> </div> <?php } } } ?> Heres what it says on screen Notice: unserialize() [function.unserialize]: Error at offset 18 of 20 bytes in C:\xampp\htdocs\Fight-Stuff\CommunicoreCMS\includes\prodtype.php on line 92 Line 92 is - $sizes = unserialize($sizes); Whats wrong?
  11. I know some of the errors are due to the form not being completed so could I run the script from another page without the browser going to that page?
  12. Thanks for that. I did a little tinkering around and got it working but I have a few questions that probably need an advanced user. First of all here is the code <?php ini_set("display_errors", "1"); error_reporting(E_ALL); //Report any errors // Create a 165x45 image $im = imagecreatetruecolor(165, 45); $white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF); $black = imagecolorallocate($im, 0x00, 0x00, 0x00); // Get the Text String from the Text Field $string = $_POST['input']; // Get the Font Type from the Menu Field $font = $_POST['fontselect']; //Set the Path to the Font Directory $font_file = 'fonts/'; //Set the Path to the uploads folder $location = 'uploads/test.png'; // Make the background black imagefilledrectangle($im, 0, 0, 164, 44, $black); // Draw the Text from Text String using font size 14 imagefttext($im, 14, 0, 30, 30, $white, $font, $string); // Output the image to the browser header('Content-Type: image/png'); //Save the image to the uploads folder imagepng($im,$location); // Clear the image from memory imagedestroy($im); ?> Question 1 I get a few notices and errors as below. How do I sort these Warning: imagefttext() [function.imagefttext]: Could not find/open font in C:\xampp\htdocs\site\includes\prodtype.php on line 27 Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\site\productdesign.php:11) in C:\xampp\htdocs\site\includes\prodtype.php on line 30 Question 2 I store the image that is created as 'test.png' in the 'uploads' folder but I tink I need to store it as something else because if 2 people are using the site at once the image will change to the latest users text so how would I store it related to the session? And would a user have to be logged in to start the session?
  13. is it somethiing to do with the imagepng($im);
  14. I am trying to create an image using PHP and GD library. What I want to do is; 1. User inputs required text 2. User selects a font from list 3. PHP and GD creates the image then saves it to the database in uploads folder 4. The generated image appears on screen after being called from the database The following code I did does most of this but the user form for this is on a page called productdisplay.php and the php script is on create text.php so when the image is created it doesn't yet save it but displays it on screen on create-text.php When the user runs the script I want to stay in the productdisplay.php page, save the image to the server then call it to the page. Heres my code <?php //Report any errors ini_set("display_errors", "1"); error_reporting(E_ALL); // Create a 165x45 image $im = imagecreatetruecolor(165, 45); $white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF); $black = imagecolorallocate($im, 0x00, 0x00, 0x00); // Get the Text String from the Text Field $string = $_POST['input']; // Get the Font Type from the Menu Field $font = $_POST['fontselect']; //Set the Path to the Font Directory $font_file = 'fonts/'; // Make the background black imagefilledrectangle($im, 0, 0, 164, 44, $black); // Draw the Text from Text String using font size 14 imagefttext($im, 14, 0, 30, 30, $white, $font, $string); // Output the image to the browser header('Content-Type: image/png'); imagepng($im); // Clear the image from memory imagedestroy($im); ?> What do I change to save the image, display on screen and stay on same page? Thanks B
  15. HI Guys I have some serialised data in my database related to the colour of a product. The data is actually a link to an image of a coloured square 22px x 22px representing a colour. In order to unserialise it and I used the following code; <?php $sql = "SELECT * FROM `products` WHERE `prod_name` = '".$_GET['nid']."' limit 1 "; $query = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($query) > 0) { while ($row = mysql_fetch_assoc($query)){ $colours = $row['prod_colours']; $colours = stripslashes($colours); $colours = unserialize($colours); $itemcount = count($colours); for ($i=0;$i<$itemcount;$i++) { ?> <div class="colours"><a href="productdesign.php?nid=<?php echo $row['prod_name']; ?>&colid="<?php echo $row['prod_colours']; ?> > <?php echo '<img src="' .$colours[$i]. '">'; ?></a></div> <?php } } } ?> But when the colour is selected I need a nedw image to appear on screen which will be the product in the required colour. How do I add a value to the coloured square so when it is clicked I can call it as 'colid', meaning the page will be; prodtype.php?nid=value&colid=value associated with square image I hope I have explained ok.
×
×
  • 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.