Jump to content

greycap

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Everything posted by greycap

  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" />
  16. [!--quoteo(post=352747:date=Mar 7 2006, 10:17 PM:name=dheon09)--][div class=\'quotetop\']QUOTE(dheon09 @ Mar 7 2006, 10:17 PM) [snapback]352747[/snapback][/div][div class=\'quotemain\'][!--quotec--] If you can see the entire code is posted above, also the Warning...after the warning there was no output...i tried setting a worng pass and user for the connection and it did show the die message so I think the query is good...do you need something else? [/quote] Ok, when I remove the clutter of the <? ?> tags, you get this: [code] $user = "user"; $pass = "pass"; $dbase = "localhost"; $uname = $_POST['user']; $upass = $_POST['pass']; $connection = mysql_connect("localhost",$user,$pass) or die ("Error Connecting to DBase"); mysql_select_db($dbase,$connection) or die ("Error Connecting to table"); $result = mysql_query("SELECT * FROM usertb",$connection) or die ("Error querying DBase"); $i = 0; while($result_ar = mysql_fetch_assoc($result)) {    mysql_close();    ob_start();    if ($upass == $result_ar['upass'] && $uname == $result_ar['uname'])    {       header("Location: clients/myoxy/index.html");    }    else       header("Location: index.html");    $i+=1; } [/code] I don't really know why youre using an ob_start() (especially without a ob_flush()) and you are also closing your connection multiple times. I'm not sure of the effect on the ob_start() and multiple header() calls, but there is no way that the results you will get from that are what you are actually looking for. Try something like this: [code]$found = false; while ($result_ar = mysql_fetch_assoc($result)) {    if (($upass == $result_ar['upass']) && ($uname == $result_ar['uname']))    {       $found = true;       break;    } } if ($found) { //valid login    header("Location: clients/myoxy/index.html"); } else { //invalid login    header("Location: index.html"); } [/code]
  17. [!--quoteo(post=336076:date=Jan 13 2006, 02:07 AM:name=unfamiliar)--][div class=\'quotetop\']QUOTE(unfamiliar @ Jan 13 2006, 02:07 AM) 336076[/snapback][/div][div class=\'quotemain\'][!--quotec--] I need a fix for this code so it displays other peoples service host <? $hostname = gethostbyaddr "60.228.82.14"; echo $hostname; ?> echo and print are very unique in that they dont require parans (). Virtually every other function does. you want: $hostname = gethostbyaddr("60.228.82.14");
  18. [!--quoteo(post=352667:date=Mar 7 2006, 05:10 PM:name=icydude)--][div class=\'quotetop\']QUOTE(icydude @ Mar 7 2006, 05:10 PM) [snapback]352667[/snapback][/div][div class=\'quotemain\'][!--quotec--] It outputs a number, ie today would be "11" i want the 25x25 "ash.png" to show the number dynamicly. [/quote] use imagestring()
  19. [!--quoteo(post=352739:date=Mar 7 2006, 10:00 PM:name=BIGDOG)--][div class=\'quotetop\']QUOTE(BIGDOG @ Mar 7 2006, 10:00 PM) [snapback]352739[/snapback][/div][div class=\'quotemain\'][!--quotec--] can someone please tell me the error in the following code? Parse error: parse error, unexpected T_STRING, expecting ',' or ';' echo "<td><a href="http://www.xxx.com/cart.php?action=add&item=".$row[product_id].""target="_blank" onMouseOver="window.status='Add To Cart!'; return true;" onMouseOut="window.status=''; return true;" onClick="window.open(this.href,0,'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=yes,width=700,height=400,top=5,left=5, resizable=yes');return false">Add To Cart!</a></td>\n"; [/quote] You have to escape the "s you actually want output. ie: echo "<img src=\"image.gif\" alt=\"A Picture\">";
  20. [!--quoteo(post=352735:date=Mar 7 2006, 09:50 PM:name=dheon09)--][div class=\'quotetop\']QUOTE(dheon09 @ Mar 7 2006, 09:50 PM) [snapback]352735[/snapback][/div][div class=\'quotemain\'][!--quotec--] can you tell me what should i do...i really need to work this out asap....as i've said before the script works on our local netwok Thanks [/quote] That $result_ar is fine. It is being initialized and set to the results of the query. If the query was bad, the die() would have been executed and your script would have halted. Can you show the entire code? And what is being output? There should be output after that warning.
  21. If theyre numbers, SELECT * FROM activity WHERE time BETWEEN 2006030700000 AND 2006070700000 If theyre dates, then you can use BETWEEN TO_DATE(start) AND TO_DATE(end). etc.
  22. [!--quoteo(post=352692:date=Mar 7 2006, 06:24 PM:name=ibzi)--][div class=\'quotetop\']QUOTE(ibzi @ Mar 7 2006, 06:24 PM) [snapback]352692[/snapback][/div][div class=\'quotemain\'][!--quotec--] Let's say I have a paragraph of text. "This forum is phpfreaks.com and the person posting this message goes by the Username of ibzi. This is just a paragraph to show an example to the fellow helpers." Now lets say I want to replace all the occurence of the word "and" regardless about the case. It can be And or AND or aND etc. How would i do this? I want to replace it with something like: and >>>>>> <a target="_blank" href="search.php?q=and">and</a> I tried preg_match but I dont know how to use the function, i constantly get wrong result near the "_blank". Please help.. it will be appreciated. [/quote] You definately want regular expressions. Try preg_replace though. There are plenty of regular expression generators to help you get it just right.
  23. [!--quoteo(post=352614:date=Mar 7 2006, 03:01 PM:name=psyion)--][div class=\'quotetop\']QUOTE(psyion @ Mar 7 2006, 03:01 PM) [snapback]352614[/snapback][/div][div class=\'quotemain\'][!--quotec--] here is my problem, i'm need to randomly pick 15 names from a table call student and store them to another table call temp_class here is the random part SELECT name FROM student ORDER BY RAND() LIMIT 15 but than how do i send this 15 names to temp_class????? [/quote] [code] INSERT INTO temp_class (    SELECT *    FROM student    ORDER BY RAND()    LIMIT 15 ) [/code] Also, in that code you posted, you cant use strings in a switch() statement.
  24. [!--quoteo(post=352727:date=Mar 7 2006, 09:31 PM:name=PWD)--][div class=\'quotetop\']QUOTE(PWD @ Mar 7 2006, 09:31 PM) [snapback]352727[/snapback][/div][div class=\'quotemain\'][!--quotec--] What is the best way to format my MySQL query if I want to display my [b]dates[/b] in ascending order? Currently, as written, my query sorts my dates [b]alphabetically[/b], and I want it sorted numerically: [code]$query = "SELECT DATE_FORMAT(date_date,'%M %D %Y') AS date_date,date_info from imp_dates ORDER BY date_date ASC";[/code] My search of the MySQL website must not be correct as I'm not producing any results about this. My gratitude ahead of time for your help... [/quote] It may be that you are hiding the column name with your alias. Your orderby is probably looking at the alias and not the original column. Try this: SELECT DATE_FORMAT(date_date,'%M %D %Y') AS date_string,date_info from imp_dates ORDER BY date_date ASC
  25. [!--quoteo(post=352725:date=Mar 7 2006, 09:24 PM:name=yahn)--][div class=\'quotetop\']QUOTE(yahn @ Mar 7 2006, 09:24 PM) [snapback]352725[/snapback][/div][div class=\'quotemain\'][!--quotec--] I take the slashes out at the end of the code, either way I canged it and it still gives the same error. Does anything else seem like it could be causing a problem? [/quote] It definately has to be something with that database query. The only way for mysql_result to fail when asking for the 0th paramater is for either no rows to be returned or an invalid query. Because $name is the only thing that isnt hardcoded into that query, and the fact that it works once, you have to be able to track it to that (or the database connection settings.) Why not do a print $query at that point and see what the output is at run-time.
×
×
  • 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.