Welcome
Username or Email:

Password:


Missing Code




[ ]
[ ]
Online
  • Guests: 22
  • Members: 0
  • Newest Member: omjtest
  • Most ever online: 396
    Guests: 396, Members: 0 on 12 Jan : 12:51
Members Birthdays:
No birthdays today

Next birthdays
05/11 ramses (16)
05/11 Arcstarter (31)
05/11 Zak (15)
Contact
If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.


Special Thanks To:
  • Aaron Holmes
  • Aaron Wheeler
  • Adam Horden
  • Alan Scrimgeour
  • Andre
  • Andrew Haynes
  • Anonymous000
  • asabase
  • Austin Weil
  • barney
  • Barry
  • Bert Hickman
  • Bill Kukowski
  • Blitzorn
  • Brandon Paradelas
  • Bruce Bowling
  • BubeeMike
  • Byong Park
  • Cesiumsponge
  • Chris F.
  • Chris Hooper
  • Corey Worthington
  • Derek Woodroffe
  • Dalus
  • Dan Strother
  • Daniel Davis
  • Daniel Uhrenholt
  • datasheetarchive
  • Dave Billington
  • Dave Marshall
  • David F.
  • Dennis Rogers
  • drelectrix
  • Dr. John Gudenas
  • Dr. Spark
  • E.TexasTesla
  • eastvoltresearch
  • Eirik Taylor
  • Erik Dyakov
  • Erlend^SE
  • Finn Hammer
  • Firebug24k
  • GalliumMan
  • Gary Peterson
  • George Slade
  • GhostNull
  • Gordon Mcknight
  • Graham Armitage
  • Grant
  • GreySoul
  • Henry H
  • IamSmooth
  • In memory of Leo Powning
  • Jacob Cash
  • James Howells
  • James Pawson
  • Jeff Greenfield
  • Jeff Thomas
  • Jesse Frost
  • Jim Mitchell
  • jlr134
  • Joe Mastroianni
  • John Forcina
  • John Oberg
  • John Willcutt
  • Jon Newcomb
  • klugesmith
  • Leslie Wright
  • Lutz Hoffman
  • Mads Barnkob
  • Martin King
  • Mats Karlsson
  • Matt Gibson
  • Matthew Guidry
  • mbd
  • Michael D'Angelo
  • Mikkel
  • mileswaldron
  • mister_rf
  • Neil Foster
  • Nick de Smith
  • Nick Soroka
  • nicklenorp
  • Nik
  • Norman Stanley
  • Patrick Coleman
  • Paul Brodie
  • Paul Jordan
  • Paul Montgomery
  • Ped
  • Peter Krogen
  • Peter Terren
  • PhilGood
  • Richard Feldman
  • Robert Bush
  • Royce Bailey
  • Scott Fusare
  • Scott Newman
  • smiffy
  • Stella
  • Steven Busic
  • Steve Conner
  • Steve Jones
  • Steve Ward
  • Sulaiman
  • Thomas Coyle
  • Thomas A. Wallace
  • Thomas W
  • Timo
  • Torch
  • Ulf Jonsson
  • vasil
  • Vaxian
  • vladi mazzilli
  • wastehl
  • Weston
  • William Kim
  • William N.
  • William Stehl
  • Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Forums
4hv.org :: Forums :: Computer Science
« Previous topic | Next topic »   

Anyone here good with PHP

 1 2 3 
Move Thread LAN_403
Carbon_Rod
Tue May 03 2011, 04:39AM
Carbon_Rod Registered Member #65 Joined: Thu Feb 09 2006, 06:43AM
Location:
Posts: 1155
Yep,
ironically on craigslist there are at least a dozen kids trying to get people to work for "shares" of a company. Now even if people ignore the fact that 50% of $0 is still $0, they are unlikely going to stick around very long with student-debt in this market. =P

Although not recommend for production environments, you could try it with:
allow_url_fopen=On
allow_url_include=On

Then read this:
Link2
Back to top
Adam Munich
Tue May 03 2011, 05:24AM
Adam Munich Registered Member #2893 Joined: Tue Jun 01 2010, 09:25PM
Location: Cali-forn. i. a.
Posts: 2242
Once again, I am a complete n00b with php. I don't even know what is going on in that scheduled task...
Back to top
Myke
Tue May 03 2011, 06:40AM
Myke Registered Member #540 Joined: Mon Feb 19 2007, 07:49PM
Location: MIT
Posts: 969
Because you are a n00b doesn't mean you can't learn. Link2

Everyone has to start somewhere. Start with something simple at first to get the feel of how things work and then work from there.
Back to top
Adam Munich
Sun May 08 2011, 12:39AM
Adam Munich Registered Member #2893 Joined: Tue Jun 01 2010, 09:25PM
Location: Cali-forn. i. a.
Posts: 2242
The thing is I need to see it in action to learn how to do it. I'm kinda figuring it out though, and the only thing that is left to do is fix the image upload issue.

However I can't seem to fix this problem; there is some blackspace above everything on the index page Link2 and I have no clue what is causing it. There is no space viewitem Link2 and postsomething Link2

wat do.

Edit: Turns out it was a simple css issue, my divs were all messed up. angry
Back to top
Adam Munich
Tue May 17 2011, 06:13AM
Adam Munich Registered Member #2893 Joined: Tue Jun 01 2010, 09:25PM
Location: Cali-forn. i. a.
Posts: 2242
Alright, so I finally have everything fixed! Link2

....except for the image issue. It needs a new image upload and thumbnail making system, and while I am learning a bit about php I still can't figure out how to implement one. I installed GD library but I'm not sure how to make it work with the database and stuff. Anyone want to take a shot at it? (please)
Back to top
Carbon_Rod
Wed May 18 2011, 01:32AM
Carbon_Rod Registered Member #65 Joined: Thu Feb 09 2006, 06:43AM
Location:
Posts: 1155
@Grenadier, test your CSS in IE6/IE7 before claiming victory over the bugs... ;-P

<?php
/* First create a sub path 'img' with a RGB jpeg file called 'some_full_size.jpg' */

/* Try this block of test code, and note the system file path is not a URL */

//get a cleaned file name from ...
$imageName=preg_replace( '/[^A-Za-z0-9]/i','_', 'some_full_size');
//create some file resource paths
$fileName=getcwd() . '/img/'.$imageName.'.jpg';
$iconFileName=getcwd() . '/img/'.$imageName. '.icon.jpg';
//width of final image
$iconWidth=120;

if(file_exists($fileName))
{
// load image and get image size
$img = imagecreatefromjpeg( fileName);
$width = imagesx( $img );
$height = imagesy( $img );

// calculate thumbnail size
$new_width = $iconWidth;
$new_height = floor( $height * ( $iconWidth / $width ) );

if($new_height > $iconWidth)
{
$new_height = $iconWidth;
}

// create a new blank image obj
$tmp_img = imagecreatetruecolor( $new_width, $new_height );

// copy and resize old image into new image
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );

// save thumbnail into a file
imagejpeg( $tmp_img, $iconFileName, 88 ); //88% image quality

//free the objs
imagedestroy($img);
imagedestroy($tmp_img);
}
$dhtml= '<img src="img/"'.$imageName.'.jpg" alt="'.$imageName.'"/>'.
'<img src="img/"'.$imageName.'.jpg.icon.jpg" alt="'.$imageName.' icon"/>';

echo $dhtml;

?>

Cheers,
Rod
Back to top
Adam Munich
Thu May 19 2011, 12:32AM
Adam Munich Registered Member #2893 Joined: Tue Jun 01 2010, 09:25PM
Location: Cali-forn. i. a.
Posts: 2242
Yay it works! I'm beginning to understand how the mysql database works, and all that is left to fix is to make sure that images get deleted when people delete the posts. I put this in action.php:



However it gives me this error;

Warning: unlink() expects parameter 1 to be string, resource given in /home/teravolt/public_html/junkbox/action.php on line 29

Warning: unlink() expects parameter 1 to be string, resource given in /home/teravolt/public_html/junkbox/action.php on line 31

How would I convert the resource to a string? I can't seem to find any information on the interwebs regarding how to do that.

Back to top
Carbon_Rod
Thu May 19 2011, 01:32AM
Carbon_Rod Registered Member #65 Joined: Thu Feb 09 2006, 06:43AM
Location:
Posts: 1155
mysql_query() returns a resource object, and not a string path name...
Link2

Back to top
Adam Munich
Thu May 19 2011, 02:11AM
Adam Munich Registered Member #2893 Joined: Tue Jun 01 2010, 09:25PM
Location: Cali-forn. i. a.
Posts: 2242
Is there a way to return a string from the mysql database?
Back to top
Carbon_Rod
Thu May 19 2011, 02:34AM
Carbon_Rod Registered Member #65 Joined: Thu Feb 09 2006, 06:43AM
Location:
Posts: 1155
imageurl = mysql_query(" ..foo.. LIMIT 0,1"); //grab only one record

while ($row = mysql_fetch_assoc($result)) { //process each returned result
$strTempName = preg_replace( '/[^0-0a-zA-Z\-\+\_]/i','',$row['imgURLThumb'] ); //get image name
unlink( getcwd() . '/img/' . $strTempName . '.jpg'); //force clean file path and name
}


You should read the samples on the posted link...
Back to top
 1 2 3 

Moderator(s): Chris Russell, Noelle, Alex, Tesladownunder, Dave Marshall, Dave Billington, Bjørn, Steve Conner, Wolfram, Kizmo, Mads Barnkob

Go to:

Powered by e107 Forum System
 
Legal Information
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.