Jump to content

fireice87

Members
  • Posts

    44
  • Joined

  • Last visited

    Never

Everything posted by fireice87

  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
  16. Hy iv looked at that example and attempted something smiliar its allmost there as when i leave the city field empty it displays all but when ever i type anything in to the city field it displays the or die error. this is my new code to try and create the sql statment dependent on the city filed <?php if (empty($City)) { $CitySQL = ""; }else { $CitySQL = "AND location = $City"; } $sql = "Select * FROM giglist WHERE genre = '$Genre' $CitySQL AND date BETWEEN '$DateFS' AND '$DateTS' ORDER BY date"; ?>
  17. Hey Iv got a form where users input details that are then used as search criteria and it all works fine as long as all the details are enterd. But if a variable is empty then this blank space is used as search criteria with doesnt match any records and thus creates no results. Below is my code what i would like help with is modifing it so the SQL ignores the clauses that use empty variables. <form id="Criteria" name="Criteria" method="post" action="gigs.php" > <table width="244" height="102" border="0" cellspacing="1"> <tr> <td width="67" height="24">Genre: </td> <td width="170"> <select name="Genre" tabindex="3"> <option value="All">All</option> <option value="Rock">Rock</option> <option value="Pop">Pop</option> <option value="Metal">Metal</option> <option value="Punk">Punk</option> <option value="Indie">Indie</option> <option value="RnB">RnB</option> <option value="Dance">Dance</option> <option value="Electronica">Electronica</option> <option value="Hip-Hop">Hip-Hop</option> <option value="Rap">Rap</option> </select></td></tr> <tr> <td width="67">City/Town</td> <td width="170" ><input type="text" name="City" tabindex="4" /></td> </tr> <tr> <td>Date From: </td> <td><input type="text" name="DateF" value="dd/mm/yyyy" onfocus="this.select();lcs(this)" onclick="event.cancelBubble=true;this.select();lcs(this)"> </td> </tr> <td>Date To: </td> <td><input type="text" name="DateT" value="dd/mm/yyyy" onfocus="this.select();lcs(this)" onclick="event.cancelBubble=true;this.select();lcs(this)"> </td> </tr> <tr> <td><input type="submit" name="Search" value="Search" tabindex="3" /></td> The date is pulled from a javascript calander and then re formatted to match the dates stored in the database Below is the reformating and the SQL search statement <?php $DateTemp = substr($DateF, 6, 7)."-".substr($DateF, 3, 3). substr($DateF, 0, 2); $DateFS = str_replace("/", "-", $DateTemp ); $DateTemp = substr($DateT, 6, 7)."-".substr($DateT, 3, 3). substr($DateT, 0, 2); $DateTS = str_replace("/", "-", $DateTemp ); $City = $sql = "Select * FROM giglist WHERE genre = '$Genre' AND location = '$City' AND date BETWEEN '$DateFS' AND '$DateTS' ORDER BY date"; ?> Iv tried placing if else rules in to the SQL statment but to no success any help would be greatly appreciated Thanks
  18. Thanks for your help got it all working now for any that are wanting some help with a similiar issue heres my finished script The form <form id="addgig" name="addgig" method="post" action="gigstore.php"> <table border="0" cellspacing="1"> <?php while($count < $Howmany) { echo "<tr height=\"22px\">\n"; echo "<td width=\"55px\" align=\"left\" valign=\"top\">"; # days echo "<select name=\"Day[]\">"; for($i=1;$i<=31;$i++){ echo "<option value=\"$i\">$i</option>\n"; } echo "</select>"; echo "</td>"; echo "<td width=\"55px\" align=\"left\" valign=\"top\">"; # months echo "<select name=\"Month[]\">"; for($j=1;$j<=12;$j++){ echo "<option value=\"$j\">$j</option>\n"; } echo "</select>"; echo "</td>"; echo "<td width=\"55px\" align=\"left\" valign=\"top\">"; # years echo "<select name=\"Year[]\">"; for($k=2030;$k>=2007;$k--){ echo "<option value=\"$k\">$k</option>\n"; } echo "</select>"; echo "</td></tr>"; $count++; } ?> <input type="submit" name="Submit" value="Submit" /> </form> to insert into the database <?php $conn = @mysql_connect( "*******", "******, "********") or die ("could not connect to mysql"); #Connect to mysql $rs = @mysql_select_db( "*******", $conn ) or die ("Could not select database"); #select database foreach ($_POST['Day'] as $i=>$Day) { $Month = $_POST['Month'][$i]; $Year = $_POST['Year'][$i]; // process date $Date = $Year."-".$Month."-".$Day; $sql = "INSERT INTO date(`date`)Values (\"$Date\")"; $result= @mysql_query($sql, $conn ) or die(" Could not add style facts"); } ?>
  19. Hey Ah thankyou i understand now thanks! Sorry i edited my first post just before you responded just to clarify my problem got the first bit of code workin that mgal showed me going to try and use your method now Thanks!
  20. lol that method does make a lot more sense i couldnt quite get it to work but i get what to do with it now thanks! im afraid i dont understand If you name the selects "day[]", "month[]" and "year[]" they will be posted in arrays for processing <?php foreach ($_POST['day'] as $k=>$day) { $month = $_POST['month'][$k]; $year = $_POST['year'][$k]; // process date } i would normally use the form input to create a value that i use sql to insert into my database Thanks for your help
  21. Intro: I a have a form for users to enter details. Before the form is shown the user enters a number of values they need to enter. So the amount the user enters first is the anount of rows the user is given to enter there details. To do this iv used a while loop and a $count variable. Problem: My problem is with echoing the form. I must be doing it in a completly non standard way as allthough firefox displays it perfectely ie doesnt display it at all. My Code: <form id="addgig" name="addgig" method="post" action="gigstore.php"> <table border="0" cellspacing="1"> <?php while($count < $Howmany) { echo "<tr height=\"22px\">\n"; echo "<td width=\"55px\" align=\"left\" valign=\"top\">"; echo "<select name=\"Day\">"; echo "<option value=$Day>$Day</option>"; echo "<option value=\"01\">01</option>"; echo "<option value=\"02\">02</option>"; echo "<option value=\"03\">03</option>"; echo "<option value=\"04\">04</option>"; echo "<option value=\"05\">05</option>"; echo "<option value=\"06\">06</option>"; echo "<option value=\"07\">07</option>"; echo "<option value=\"08\">08</option>"; echo "<option value=\"09\">09</option>"; echo "<option value=\"10\">10</option>"; echo "<option value=\"11\">11</option>"; echo "<option value=\"12\">12</option>"; echo "<option value=\"13\">13</option>"; echo "<option value=\"14\">14</option>"; echo "<option value=\"15\">15</option>"; echo "<option value=\"16\">16</option>"; echo "<option value=\"17\">17</option>"; echo "<option value=\"18\">18</option>"; echo "<option value=\"19\">19</option>"; echo "<option value=\"20\">20</option>"; echo "<option value=\"21\">21</option>"; echo "<option value=\"22\">22</option>"; echo "<option value=\"23\">23</option>"; echo "<option value=\"24\">24</option>"; echo "<option value=\"25\">25</option>"; echo "<option value=\"26\">26</option>"; echo "<option value=\"27\">27</option>"; echo "<option value=\"28\">28</option>"; echo "<option value=\"29\">29</option>"; echo "<option value=\"30\">30</option>"; echo "<option value=\"31\">31</option>"; echo "</select>"; echo "</td>\n"; echo "<td width=\"55px\" align=\"left\" valign=\"top\">"; echo "<select name=\"Month\">"; echo "<option value=$Month>$Month</option>"; echo "<option value=\"01\">01</option>"; echo "<option value=\"02\">02</option>"; echo "<option value=\"03\">03</option>"; echo "<option value=\"04\">04</option>"; echo "<option value=\"05\">05</option>"; echo "<option value=\"06\">06</option>"; echo "<option value=\"07\">07</option>"; echo "<option value=\"08\">08</option>"; echo "<option value=\"09\">09</option>"; echo "<option value=\"10\">10</option>"; echo "<option value=\"11\">11</option>"; echo "<option value=\"12\">12</option>"; echo "</select>"; echo "</td>\n"; echo "<td width=\"55px\" align=\"left\" valign=\"top\">"; echo "<select name=\"Year\">"; echo "<option value=$Year>$Year</option>"; echo "<option value=\"07\">07</option>"; echo "<option value=\"08\">08</option>"; echo "<option value=\"09\">09</option>"; echo "<option value=\"10\">10</option>"; echo "<option value=\"11\">11</option>"; echo "<option value=\"12\">12</option>"; echo "<option value=\"13\">13</option>"; echo "<option value=\"14\">14</option>"; echo "<option value=\"15\">15</option>"; echo "<option value=\"16\">16</option>"; echo "<option value=\"17\">17</option>"; echo "<option value=\"18\">18</option>"; echo "<option value=\"19\">19</option>"; echo "<option value=\"20\">20</option>"; echo "</td>\n</tr>\n"; $count++; } ?> Any help would be greatly appreciated
  22. Thank you that works brilliantly! at first it was throwing up "Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING on llin 46- 48 after playing about for a bit i copied the method u used on . substr($row['location'], 0, 15) . and added the full stops so turned it into echo " <td width=\"130px\" align=\"center\">" . $row['date'] . "</td>\n"; I dont know why that worked though? Iv seen these full stops in code before but didnbt come across it when i was learning the basic php syntax Thanks again !
  23. Hey im trying to make a table that is built with a php loop that selects data from a mysql database. iv created the table and made the loop. The problem im having is with the table formatting it seems very awkward to try and get it how i want as its hard to see why some of the issues are occuring. Heres an image of the table, below the image is the code, then what i need help changing thanks! <?php $sql = "Select * FROM giglist"; //pull the users from the table $result= @mysql_query($sql, $conn ) or die(" Could not add style facts"); echo "<table border=\"1\">"; // display the users in table $c = 0; while($row = mysql_fetch_array($result)) { $date = $row['date']; $band = $row['band']; $venue = $row['venue']; $location = $row['location']; $numattending = $row['numattending']; $numcomments = $row['numcomments']; $addedby = $row['added_by']; echo "<tr height=\"20px\">"; // If the counter has ticked 6 times, start a new row. echo "<td width=\"50px\"align=center>", $date; ?></td><? echo "<td width=\"120px\"align=center>", $band; ?> </td><? echo "<td width=\"230px\"align=center colspan=\"2\">", $venue; ?> - <? echo $location; ?> </td></tr><? echo "<tr height=\"20px\"align=center>"; echo "<tr width=\"50px\"align=center>"; echo "<td width=\"130px\"align=center>" ?><img src="ContactInvite.jpg" alt="num attending" /> <? echo $numattending; ?></td> <? echo "<td width=\"120px\"align=center>" ?><img src="Comment.jpg" alt="Comments" /> <? echo $numcomments; ?></td> <? echo "<td width=\"120px\"align=center>" ?><img src="Write.jpg" alt="Added by" /> <? echo $addedby; ?></td><? echo "</tr>"; } echo "</table>"; ?> My main problem is the white space between the rows i have no idea why thats being created and have tried re writing the code in diffrent ways but cant get rid of it. Allthough a diffrent issue im allso confused how to shorten a variable. for example if the location varaiable was to long to display how would i only show the first 15 characters? Thanks for anyhelp
  24. iv got two pages ones got a form that where a user can choose an image to upload the other page i ssupposed to store it iv used variations of this code many times im trying to use it now but im stumped because it looks absoultley fine to me but its just not working but the original image witch is suppsoed to be stored then resized then deleted seems to never be saved http://www.thewu.site23.co.uk/createplace.php <FORM ENCTYPE="multipart/form-data" ACTION= "storeplace.php" METHOD=POST> <table width="302" border="0"> <tr> <td colspan="2"><H7>Name:</H7></td> <td width="221" colspan="2"><input name="PName" type="text" tabindex="1"/></td> </tr> <tr> <td colspan="2"><H7>Category:</H7></td> <td colspan="2"><select name="Category" tabindex="2"> <option value="<?php echo ($Category) ?>"><?php echo ($Category) ?> </option> <option value="Pub/Club">Pub/Club</option> <option value="Restaurant">Restaurant</option> <option value="Eatery/Cafe">Eatery/Cafe</option> <option value="Shop">Shop</option> <option value="Body/Fitness">Body/Fitness</option> <option value="Park/Nature">Park/Nature</option> <option value="Other">Other</option> </select></td> </tr> <tr> <td colspan="2"><H7>Picture: </H7></td> <td colspan="2"><input name="image1" type="file" tabindex="2" /></td> </tr> <tr> <td colspan="2"> <td colspan="2"><input name="submit" type="submit" value="Submit pics and details" tabindex="3"/></td> </tr> </table> </form> on submitting the seconed page that is supposed to store the images produces many lines of error like these Warning: imagecreatefromjpeg(Places/2352/image1.jpg) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in /home/site23/public_html/thewu/storeplace.php on line 37 Warning: getimagesize(Places/2352/image1.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /home/site23/public_html/thewu/storeplace.php on line 40 Warning: Division by zero in /home/site23/public_html/thewu/storeplace.php on line 54 heres the code for that page <?php $count = $_COOKIE['members']; $user = $_COOKIE['username']; $text = ("You are logged in as $user, you are 1 of $count members ") ; $conn = @mysql_connect( "********", "******", "*****") or die ("could not connect to mysql"); #Connect to mysql $rs = @mysql_select_db( "site23_thewu", $conn ) or die ("Could not select database"); #select database $sql = "INSERT INTO places_basics(`name`,`category`,`pic`)VALUES (\"$PName\",\"$Category\",'image')"; $run= @mysql_query($sql, $conn ) or die(" Could not add"); mkdir("Places/$PName"); mkdir("Places/$PName/Standard"); mkdir("Places/$PName/Small"); mkdir("Places/$PName/Tiny"); if ($Image1_size >250000){$msg=$msg."Your uploaded file size is more than 250KB so please reduce the file size and then upload.<BR>"; $file_upload="false";} if (!($Image1_type =="image/pjpeg" OR $Image1_type=="image/gif")){$msg=$msg."Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>"; $file_upload="false";} $add="Places/$PName/image1.jpg"; // the path with the file name where the file will be stored, upload is the directory name. if(move_uploaded_file ($Image1, $add)){ // do your coding here to give a thanks message or any other thing. }else{echo " ";} // make tmep file $uploadedfile = "Places/$PName/image1.jpg"; $src = imagecreatefromjpeg($uploadedfile); // get size of image list($width,$height)=getimagesize($uploadedfile); // set resize er size if ($width > $height) { $target_width=550; $ratio = $target_width/$width; $newwidth = $width * $ratio; $newheight = $height * $ratio; } else { $target_height = 450; $ratio = $target_height/$height; $newwidth = $width * $ratio; $newheight = $height * $ratio; } $tmp=imagecreatetruecolor($newwidth,$newheight); // resize imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); // save resized $filename = "Places/$PName/Standard/image1.jpg"; $_FILES['image1']['name']; imagejpeg($tmp,$filename,100); ////////////////////////////////////Make small version of image for profile // make tmep file $uploadedfile = "Places/$PName/image1.jpg"; $src = imagecreatefromjpeg($uploadedfile); // get size of image list($width,$height)=getimagesize($uploadedfile); // set resize er size if ($width > $height) { $target_width=250; $ratio = $target_width/$width; $newwidth = $width * $ratio; $newheight = $height * $ratio; } else { $target_height = 250; $ratio = $target_height/$height; $newwidth = $width * $ratio; $newheight = $height * $ratio; } $tmp=imagecreatetruecolor($newwidth,$newheight); // resize imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); // save resized $filename = "Places/$PName/Small/image1.jpg"; $_FILES['image1']['name']; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); ////////////////////////////////////Make tiny version of image for searces $uploadedfile = "Places/$PName/image1.jpg"; $src = imagecreatefromjpeg($uploadedfile); // get size of image list($width,$height)=getimagesize($uploadedfile); // set resize er size if ($width > $height) { $target_width=110; $ratio = $target_width/$width; $newwidth = $width * $ratio; $newheight = $height * $ratio; } else { $target_height = 110; $ratio = $target_height/$height; $newwidth = $width * $ratio; $newheight = $height * $ratio; } $tmp=imagecreatetruecolor($newwidth,$newheight); // resize imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); // save resized $filename = "Places/$PName/Tiny/image1.jpg"; $_FILES['image1']['name']; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); $delete = unlink("Places/$PName/image1.jpg"); header("Location: ./createplace2.php"); ?> it creates thje folder on the server for exmaple /Places/2352/Standard but no image i cant see why so any help or advie would be greatly appreciated
  25. And a good idea it was thanks For anyone who finds this thread looking for a solution heres my function to help <?php $uploadedfile = "DisplayPic/$user.jpg"; $src = imagecreatefromjpeg($uploadedfile); // get size of image list($width,$height)=getimagesize($uploadedfile); if ($width > $height) { $target_width=110; $ratio = $target_width/$width; $newwidth = $width * $ratio; $newheight = $height * $ratio; } else { $target_height = 110; $ratio = $target_height/$height; $newwidth = $width * $ratio; $newheight = $height * $ratio; $tmp=imagecreatetruecolor($newwidth,$newheight); } // resize imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); // save resized $filename = "DisplayPic_Tiny/$user.jpg"; $_FILES['userfile']['name']; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); ?> Thanks again for your help
×
×
  • 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.