Jump to content

greycap

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

greycap's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [!--quoteo(post=355272:date=Mar 15 2006, 02:33 AM:name=keeB)--][div class=\'quotetop\']QUOTE(keeB @ Mar 15 2006, 02:33 AM) [snapback]355272[/snapback][/div][div class=\'quotemain\'][!--quotec--] It works fine for me like this.. [code] class fooooooo {     public function bar($s1) {         $foo = new bar($RAWR);         $foo->method();     } }[/code] To each their own [= [/quote] Keeb, yours isnt the same. In the other two examples, the variable is a member of the class. Your $foo is local to bar().
  2. [!--quoteo(post=355214:date=Mar 14 2006, 09:54 PM:name=soccer022483)--][div class=\'quotetop\']QUOTE(soccer022483 @ Mar 14 2006, 09:54 PM) [snapback]355214[/snapback][/div][div class=\'quotemain\'][!--quotec--] I'm creating a classified ads system online. Here's my problem: When someone creates a new ad, they can upload an image. If they upload an image, but end up not creating the ad, I need to delete the image. Do you think this is the best way to do it? [/quote] Its ok to have a clean-up process on an aborted transaction. Another solution is that, because it sounds like an image is optional, only allow image to ads that have been already been created.
  3. value cant be set with file inputs.
  4. [!--quoteo(post=355235:date=Mar 15 2006, 12:13 AM:name=cheyner11)--][div class=\'quotetop\']QUOTE(cheyner11 @ Mar 15 2006, 12:13 AM) [snapback]355235[/snapback][/div][div class=\'quotemain\'][!--quotec--] I need some help columizing data into three rows. what would the PHP code be to create a data print like the following: data A | data B | data C Thanks for your help [/quote] [code] <?php $sql = "SELECT a, b, c FROM T"; $result = mysql_query($sql) or die(mysql_error()); print "<table>"; while ($row = mysql_fetch_assoc($result)    print "<tr><td> $row['a'] </td><td> $row['b'] </td> <td> $row['c']</td></tr>"; print "</table>"; ?> [/code]
  5. A couple of ways that you can use. [b]1) Put your html in print statements:[/b] [code]    print "<htm>" .         "<head><title> $pageTitle </title></head>" .         "<body>"; /* etc */ [/code] [b]2) Use place holders and then parse your text.[/b] [code]$html = <<< HTML <h2>[TITLE]<h2> Posted [DATE] by [AUTHOR] HTML; $search = array($postTitle, $postDate, $postAuthor); $repace = array('[TITLE]', '[DATE]', '[AUTHOR]'); $html = str_replace($search,$replace,$html); print $html; [/code] The good thing about the second method is that you can read that from a file. I typically have html files with variable place holders for different sections of the page (header, footer, navbar, etc). The best thing about this method is that you are separating your content from your code. If you do it properly, you can adjust one without messing up the other. Also works well when you start working with someone who has little or no programming knowledge.
  6. [!--quoteo(post=355262:date=Mar 15 2006, 02:00 AM:name=shortj75)--][div class=\'quotetop\']QUOTE(shortj75 @ Mar 15 2006, 02:00 AM) [snapback]355262[/snapback][/div][div class=\'quotemain\'][!--quotec--] this is the part of the code that is inserting twice [code]$cat=$_POST['cid']; $for=$_POST['fid']; $user=$_SESSION['user']; $date=date("n/j/y g:i:s A"); $title=$_POST['title']; $subject=$_POST['subject']; $post=$_POST['post']; $sql="INSERT into posted(forum,cat,user,date,title,subject,post)values('$for', '$cat', '$user', '$date', '$title', '$subject', '$post')"; mysql_query($sql) or die ("Could not Post");[/code] [/quote] Your insert takes place inside a while loop which iterates through each row returned in "SELECT * from forum"
  7. [!--quoteo(post=354347:date=Mar 12 2006, 05:21 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 12 2006, 05:21 PM) [snapback]354347[/snapback][/div][div class=\'quotemain\'][!--quotec--] Without seeing your code, no one will even [b]specukate[/b] on the problem. Ken [/quote] I once specukated all over my date on a roller coaster.
  8. [!--quoteo(post=354023:date=Mar 11 2006, 04:03 PM:name=russia5)--][div class=\'quotetop\']QUOTE(russia5 @ Mar 11 2006, 04:03 PM) [snapback]354023[/snapback][/div][div class=\'quotemain\'][!--quotec--] [b]I was told, that using php, you could make a file restrictive to other than the normal ugo that you find in the CPanel.[/b] [/quote] You heard wrong, mate. As far as user permissions go, php just does what the system lets it.
  9. [!--quoteo(post=354126:date=Mar 12 2006, 02:12 AM:name=keeB)--][div class=\'quotetop\']QUOTE(keeB @ Mar 12 2006, 02:12 AM) [snapback]354126[/snapback][/div][div class=\'quotemain\'][!--quotec--] You can also use JScript as a validation tool before submit.. [/quote] Yes. But never rely on client side validation. If youre going to validate it on the client, you should still validate on the server side.
  10. The problem is that you arent handling the case of when youve found the parent array. Youre only looking for correct values. You have to be able to single all the way up the stack that its succeeded. [code] function getNavItemIndex($navItem, $haystack) {    $thisIndex = false; //default case    foreach ($haystack as $k => $v)    {       if (is_array($v))       {          $recurNdx = getNavItemIndex($navItem, $v);          if ($recurNdx !== false) //found in recursive call             return "[$k]$recurNdx";       } else          if ($v == $navItem) //found here.             return "[$k]";    }    return $thisIndex; } [/code] Should return "[2][name]"
  11. [!--quoteo(post=354111:date=Mar 12 2006, 12:58 AM:name=pixeltrace)--][div class=\'quotetop\']QUOTE(pixeltrace @ Mar 12 2006, 12:58 AM) [snapback]354111[/snapback][/div][div class=\'quotemain\'][!--quotec--] is that wrong? i just assigned a variable for event_date ( uRow[0] ) any suggestions that would fix my problem? thanks! [/quote] SELECT event_date FROM events WHERE event_date >= SYSDATE()
  12. [!--quoteo(post=352825:date=Mar 8 2006, 06:40 AM:name=AV1611)--][div class=\'quotetop\']QUOTE(AV1611 @ Mar 8 2006, 06:40 AM) [snapback]352825[/snapback][/div][div class=\'quotemain\'][!--quotec--] This might me easier: [code] if(expression) { die('warning message here'); } else{ // Execute some other exciting code here! } [/code] or do i need to put something in the brackets (maybe the name of the php file?) [/quote] You can skip the else { }.
  13. [!--quoteo(post=352757:date=Mar 7 2006, 10:51 PM:name=MartinaL)--][div class=\'quotetop\']QUOTE(MartinaL @ Mar 7 2006, 10:51 PM) [snapback]352757[/snapback][/div][div class=\'quotemain\'][!--quotec--] I updated but still no luck, nothing at all is displayed on the page. I'm fairly new to PHP so to check each line to see if it fails how do I do this? [/quote] The other problem is this: $num=mysql_numrows($result); Theres no such thing as mysql_numrows() its mysql_num_rows(). This will make $num = null which is why that loop is never entered. Dont you have error messages turned on?
  14. [!--quoteo(post=352755:date=Mar 7 2006, 10:45 PM:name=stuntasticaudi)--][div class=\'quotetop\']QUOTE(stuntasticaudi @ Mar 7 2006, 10:45 PM) [snapback]352755[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hello, I've been looking for help for a while now and cant get anyone to help me. I have classifieds php script. When a user registers it works fine, they can place an ad and it all gets stored in mysql database. But when they try to update their ad it lets them do it but when we go back and look at the ad it is still the same. In mysql nothing has been changed. Why isnt it updating? What should i look for? If i post that specific php file here would anyone be able to figure out? Would anyone like to take a look at my script and see. [/quote] Yeah, post the part where you are updating the database.
  15. [!--quoteo(post=352748:date=Mar 7 2006, 10:18 PM:name=Corbin)--][div class=\'quotetop\']QUOTE(Corbin @ Mar 7 2006, 10:18 PM) [snapback]352748[/snapback][/div][div class=\'quotemain\'][!--quotec--] Unless I'm crazy, which I wouldnt doubt that I am, if you define a variable multiple times and then echo it, it will echo the most recent definition... [/quote] Thats not redefinition, its concatenation. Notice the .=? Its like saying $form = $form . "string"; The problem is actually in your html, not your php. A submit button isnt of type button, its of type submit. <input type="Submit" name="Submit" />
×
×
  • 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.