Jump to content

fireice87

Members
  • Posts

    44
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

fireice87's Achievements

Member

Member (2/5)

0

Reputation

  1. Just having an annoying moment where i really cant see the problem so any help would be great I have a form that passes to reg_confirm.php that has the insert script i can echo out the variables on this page. heres the code <?php require('functionlist.php'); dbconnect(); $submitted = date('j F Y hA'); /* echo $_POST[title]; echo $_POST[first_name]; echo $_POST[email]; echo $_POST[first_name]; echo $_POST[telephone]; echo $_POST[pcode]; echo $_POST[time_call]; */ $sql = "INSERT INTO `training` (`tr_title` ,`tr_firstnames` ,`tr_email` ,`tr_telephone` , `tr_time` ,`tr_postcode`,`tr_date` ) VALUES (\"$_POST[title]\",\"$_POST[first_name]\",\"$_POST[email]\", \"$_POST[telephone]\", \"$_POST[time_call]\", \"$_POST[pcode]\",\"$submitted\");"; #Create Query $result= mysql_query($sql, $conn ) or die(mysql_error()); #Run query heres a copy and paste of table fields from phpmyadmin tr_title tr_firstnames tr_email tr_telephone tr_time tr_postcode tr_date Thanks alot edit forgot to post the connection! <?php function dbconnect() { global $conn, $db; $conn = @mysql_connect( "**", "**", "**") or die ("could not connect to mysql"); #Connect to mysql $db = @mysql_select_db( "**", $conn ) or die ("Could not select database"); #select database } ?>
  2. Thanks alot, the single quotes are working perfectly strange though i've always used "<\tr>" and this is the only time its caused an issue Thanks Again!
  3. hi im working on a site http://www.gigshare.net/UrbanGadgeteer/index.php?pageno=2 the data on the products is pulled from a database and printed out on this page. but it is proceded by mutiple < r> symbols. Iv been through my code that creates the table and //commented out sections to see if there was an odd typo but it is always happening. Is this error caused by an incorrect use of a function? there are less < r> symbols on a page with less products http://www.gigshare.net/UrbanGadgeteer/index.php?page=cat&sub=6 here is the code <?php $count =0; echo "<table>"; while ($count < $rows_per_page && $count < $num) { $row = mysql_fetch_array($result); $disc_display = substr($row['description'], 0, 80); echo "<tr>"; echo "<td width=\"170\" align=\"center\" rowspan=\"5\" height=\"135\"> <img src='Images/small_product_image/".$row['prod_id']."/0.jpg' alt=\"Image Unavailable\" /> </td>"; echo "<td align=\"left\" width=\"250\" valign\"top\" height=\"15\" class=\"product\">".$row['product']."</td>"; echo "<td align=\"left\" height=\"15\" class=\"moreinfo\"> Customer rating 4/5 </td>"; echo "<\tr>"; echo "<tr>"; echo "<td align=\"left\" height=\"15\" class=\"desc\">$disc_display </td>"; echo "<\tr>"; echo "<tr>"; echo "<\tr>"; echo "<tr>"; echo "<td align=\"left\" height=\"15\" valign\"top\" class=\"moreinfo\"> <a class=\"product\" href=\"index.php?page=prod&p=".$row['prod_id']."\">View product details</a> </td>"; echo "<td align=\"left\" height=\"15\" class=\"price\">Just £".$row['price']."</td>"; echo "<\tr>"; echo "<tr>"; echo "<td align=\"left\" height=\"15\" class=\"price\"></td>"; echo "<td align=\"left\" height=\"20\"><a href=\"basket.php?action=add&p=".$row['prod_id']."\"><img src=\"Images/addtobasket.gif\" alt=\"Add To Basket\" /></td>"; echo "<\tr>"; $count++; } echo "</table>"; Anyone seen this before, any ideas? Much appreciated, thanks
  4. Hey I've got a form that lets users upload 3 images, these are then stored in a temp folder. I Then resized the 3 images. I'am attempting to re-code this re-sizing script into a function as good practice, but it doesnt seem that the file paths that are stored in the variables $path1,$path2,$path3 make it to the function, the error messages thrown suggests this. Thanks for any help should hopefully be quite simple for those familiar with wrinting functions. cheers To call the function id give it the variables to use(do these need to be global?) [code] <?php image_handler($path1, $path2, $path3, $prod_id); ?> The function <?php function image_handler() { mkdir("../Images/small_product_image/$prod_id/"); mkdir("../Images/large_product_image/$prod_id/"); $c = 0; if ($c < 2) { if($c=0) {$image = $path1;} else if($c=1) {$image = $path2;} else $image = $path3; $ext = substr($image, -3); //get extension $x = @getimagesize($image); // get image size $sw = $x[0]; // image width $sh = $x[1]; // image height $w = 150; //new width $wb = 350; //new width for large image $h = (100 / ($sw / $w)) * .01; $h = @round ($sh * $h); //new hieght $hb = (100 / ($sw / $wb)) * .01; $hb = @round ($sh * $hb); //new hieght $im = @ImageCreateFromJPEG ($image) or // Read JPEG Image $im = @ImageCreateFromPNG ($image) or // or PNG Image $im = @ImageCreateFromGIF ($image) or // or GIF Image $im = false; // If image is not JPEG, PNG, or GIF $thumb = @ImageCreateTrueColor ($w, $h); // Create the resized image destination $thumbb = @ImageCreateTrueColor ($wb, $hb); @ImageCopyResampled ($thumb, $im, 0, 0, 0, 0, $w, $h, $sw, $sh); // Copy from image source, resize it, and paste to image destination @ImageCopyResampled ($thumbb, $im, 0, 0, 0, 0, $wb, $hb, $sw, $sh); $filename = "../Images/small_product_image/$prod_id/$c.".$ext; $filenameb = "../Images/large_product_image/$prod_id/$c.".$ext; imagejpeg($thumb,$filename,100); imagejpeg($thumbb,$filenameb,100); $c++; } } ?> Error messages [/code]
  5. Hey I know the code i've got here works fine, but i feel I've iv learnt enough about php now to start writing code with functions and includes. The issue im having i think is due to the way im trying to get variables from the function. below is the important bits from my code: index.php <?php require('Functions/functionlist.php'); ?> <body> <div class="#container" id="container"> <?php require('Includes/header.php'); ?> <?php require('Includes/left_column.php'); ?> <?php require('Includes/featured_products.php'); ?> </div> </body> featured_products.php <div class="#products" id="products"> <? dbconnect($conn, $db); $sql = "Select * FROM ug_products"; $result= @mysql_query($sql, $conn )or die("Could not pull products"); ?> functionlist.php <?php function dbconnect($conn, $db) { $conn = @mysql_connect( "*****", "*****, "*****") or die ("could not connect to mysql"); #Connect to mysql $db = @mysql_select_db( "gigshare_site", $conn ) or die ("Could not select database"); #select database } dbconnect($conn, $db) ?> All i keep getting is the "Could not pull products" statment ffrom my sql or die script. This code worked fine before i re-formatted it into functions. Im pretty sure its to do with the $conn variable. Any help would be much appreciated Thanks
  6. Hey Thanks that works great sorry for taking awhile to reply had to look up the diffrence betwenn relative paths and absolute i had a general idea but didnt know about things like the '..' to move up a directory. thanks
  7. Hey My file structure is as follows Site\ Images\ Large_product_image Small_product_image Includes\ Scripts\ Im trying to use mkdir in a script that is within the scripts folder. The directory im trying to create is Images\Small_product_image\$prod_id. Here is the script to make the directory <?php mkdir("\Images\small_product_image\$prod_id"); copy($_FILES['$thumb'], "/Images/small_product_image/$prod_id/$thumb"); ?> I've tried mulitple combinations (as in file paths) but keep getting file exsist error. can create a folder with in the same folder the script is in fine. Any help would be great, thanks
  8. ;D perfect that works exactly right, thanks to both of you for taking the time to help me out!
  9. to:Zhadus ah thanks for clearing that up for me its much appreciated but unfourtently its still printing the same way 1 table per row going down vertically.... if($c%2 == 0) echo "<tr>"; code if($c%2 !== 0) echo "</tr>"; to: dark_mirage Thanks yeah thats a good way to do it but doesnt work so well when you dont know how many rows need to be printed. i could use that method and have '$MyNumber' as 2 for example but that would only work for starting one more row.
  10. Thanks but i have tried it as c%2 == 0 and c%2 == 1 And still no success. I thought $c%1 == 0 would work before as the count starts from 0 so 1 has the value of 2 so the integer would be being divded by 2?
  11. Hey I have been playing with this code still to no avail. Im trying to use the % operator to say when tostart a new row. But am unsure if it will work with the values im using. to create a row. if($c%1 == 0) echo "<tr>"; so if the c variable has gone throught twice make a new row. and at the end if($c%1 !== 0) echo "</tr>"; if this is the seconed count end the row Am i using this wrong as by my understanding of the % operator that looks ok but is still not printing correctly. prints the tables out vertically <?php $c = 0; echo "<table>"; while($row = mysql_fetch_array($result)) { $product = $row['product']; $image = $row['image']; $price = $row['price']; $desc = $row['description']; $disc_display = substr($desc, 0, 210); if($c%1 == 0) echo "<tr>"; echo "<tr height=\"20px\">"; echo "<td width=\"160\" height=\"150\" rowspan=\"5\" > <img src='".$image."' alt=\"Image Unavailable\" /> </td>"; echo "<td align=\"center\" width=\"177\" class=\"product\">$product</td>"; echo "</tr>"; echo "<tr>"; echo "<td align=\"center\" height=\"20\" class=\"price\">Just £$price</td>"; echo "</tr>"; echo "<tr>"; echo "<td align=\"center\" height=\"20\" class=\"moreinfo\"> more info </td>"; echo "</tr>"; echo "<tr>"; echo "<td align=\"center\" height=\"20\" class=\"moreinfo\"> Customer rating 4/5 </td>"; echo "</tr>"; echo "<tr>"; echo "<td align=\"center\" height=\"20\"><img src=\"Images/Addtobasket.gif\" alt=\"Add To Basket\" /></td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan=\"2\" align=\"left\" class=\"desc\">$disc_display.......................</td>"; echo "</tr>"; if($c%1 !== 0) echo "</tr>"; $c++; } echo "</table>"; ?>
  12. Hey Im creating a catalog type script. I've wrote code to stick the data in the database and pull it back out in a table in a format im happy with. This table displays one catalog item. the script runs through all rows and prints the tables vertically so you get one tabel at the top then one bellow it and so on. Im trying to write the script so that instead of going straight down the tables are out putted in rows of two. I thought this would be quite easy but cant get it to work. I sent up a count and tried to put the table with the info inside a parent table that would print a new cell when the counter hits two but this had the effect of printing each table the same way but out horizontally instead of vertically! My code: (version that prints horizontally <? $sql = "Select * FROM ug_products"; $result= @mysql_query($sql, $conn )or die("Could not pull products"); $c = 0; echo "<table>"; while($row = mysql_fetch_array($result)) { $product = $row['product']; $image = $row['image']; $price = $row['price']; $desc = $row['description']; $disc_display = substr($desc, 0, 210); if($c=1) echo "<td>"; echo "<table>"; echo "<tr height=\"20px\">"; echo "<td width=\"160\" height=\"150\" rowspan=\"5\" > <img src='".$image."' alt=\"Image Unavailable\" /> </td>"; echo "<td align=\"center\" width=\"177\" class=\"product\">$product</td>"; echo "</tr>"; echo "<tr>"; echo "<td align=\"center\" height=\"20\" class=\"price\">Just £$price</td>"; echo "</tr>"; echo "<tr>"; echo "<td align=\"center\" height=\"20\" class=\"moreinfo\"> more info </td>"; echo "</tr>"; echo "<tr>"; echo "<td align=\"center\" height=\"20\" class=\"moreinfo\"> Customer rating </td>"; echo "</tr>"; echo "<tr>"; echo "<td align=\"center\" height=\"20\"><img src=\"Images/Addtobasket.gif\" alt=\"Add To Basket\" /></td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan=\"2\" align=\"left\" class=\"desc\">$disc_display.......................</td>"; echo "</tr>"; echo "</table>"; if($c=1) echo"</td>"; $c++; } echo "</table>"; ?> Thanks for any help
  13. Hey Im trying to pull an image path out of my database and use it with 'img src' to display an image. The data is coming from the database because all the other data is displaying fine have triple checked for typos and tried lots of varations on img src='".$image."' , img src='$image' , ".$image." .etc heres the code in question: echo "<td width=\"160\" height=\"150\" rowspan=\"5\" > <img src='".$image."' alt=\"Image Unavailable\" /> </td>"; The alt message does show Thanks for any help Edit: also have tested by typing <img src=\"Images/imagename.gif\" to make sure the file path from the database is correct
  14. Thankyou very much for your help people that works perfectly roopurt18
  15. Hey thanks for the quick reply with the code formatted that way it errors out to the or die statement with the input empty or with a correct or incorrect value. i think its the ', ' causing that so tried taking that out but leaving in the single quotes but goes back to how it was before. displays all results if nothing is enterd but errors to the or die statment if the input field has a value i think this is along the right lines though the formatting just isnt quite right
×
×
  • 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.