Jump to content

redbullmarky

Staff Alumni
  • Posts

    2,863
  • Joined

  • Last visited

    Never

Everything posted by redbullmarky

  1. [!--quoteo(post=358289:date=Mar 25 2006, 05:46 PM:name=scraptoft)--][div class=\'quotetop\']QUOTE(scraptoft @ Mar 25 2006, 05:46 PM) [snapback]358289[/snapback][/div][div class=\'quotemain\'][!--quotec--] Just tested it, unfortunatly it didn't ouput anything; just a blank page. [/quote] possibly an error, but if your error_reporting is off, you wont see it. either way, mlin pretty much summed it up, and redarrow is pretty much spot on: [code] $article = article text goes here $max_len = 200; $article_len = strlen($article); if ($article_len>$max_len) {    $article = substr($article,0,$max_len)."...";    $article.= "<a href='pathtoarticle.php'>[more]</a>"; } echo $article; [/code] i've not written it around your code, but it'll give you the right idea to get it working yourself based on what you have already. Hope it helps Cheers
  2. [!--quoteo(post=358288:date=Mar 25 2006, 05:45 PM:name=sarabjit)--][div class=\'quotetop\']QUOTE(sarabjit @ Mar 25 2006, 05:45 PM) [snapback]358288[/snapback][/div][div class=\'quotemain\'][!--quotec--] Thanks!! [/quote] just to elaborate on what Hooker said, ALWAYS ALWAYS ALWAYS use $_GET if refering to a URL parameter. and ALWAYS ALWAYS ALWAYS use $_POST if refering to variables posted by a form. i've been done over with this in the past, as not paying attention to where you want the variables to come from can lead to all sorts of problems.
  3. [!--quoteo(post=358245:date=Mar 25 2006, 04:31 PM:name=andy75180)--][div class=\'quotetop\']QUOTE(andy75180 @ Mar 25 2006, 04:31 PM) [snapback]358245[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hi, Does anyone know of any php scripts around that can play chess as an artifical intellegence player? It wouldn't have to output any graphics, just return what position and piece it decided to move. Any help with this one? Bit of a strange one I know. [/quote] Andy You'd have been better posting this in the 3rd party scripts forum. Either way, the first result that comes up typing 'php chess' into google is: [a href=\"http://www.redlionwebdesign.com/phpchess.htm\" target=\"_blank\"]http://www.redlionwebdesign.com/phpchess.htm[/a]
  4. can you post the exact error that you're getting?
  5. [!--quoteo(post=358274:date=Mar 25 2006, 05:19 PM:name=Essjay_d12)--][div class=\'quotetop\']QUOTE(Essjay_d12 @ Mar 25 2006, 05:19 PM) [snapback]358274[/snapback][/div][div class=\'quotemain\'][!--quotec--] still getting errors though .. changed it to both the following error for .. <?php include('../dvdreviewer/accessKey.html'); ?> ..... Warning: main(C:/Program Files/Apache Group/Apache2/htdocs/dvdreviewer/accessKey.html): failed to open stream: No such file or directory in C:\Program Files\Apache Group\Apache2\htdocs\dvdreviewer\default.php on line 469 Warning: main(): Failed opening 'C:/Program Files/Apache Group/Apache2/htdocs/dvdreviewer/accessKey.html' for inclusion (include_path='.;c:\php4\pear') in C:\Program Files\Apache Group\Apache2\htdocs\dvdreviewer\default.php on line 469 [/quote] are you 100% that accessKey.html is: a) in the dvdreviewer folder b) in the same case as you're specifying? most things like this are case sensitive.
  6. [!--quoteo(post=358279:date=Mar 25 2006, 05:25 PM:name=pcoll)--][div class=\'quotetop\']QUOTE(pcoll @ Mar 25 2006, 05:25 PM) [snapback]358279[/snapback][/div][div class=\'quotemain\'][!--quotec--] hi, how do i determine dinamically the type of a form field? i nned to know wich is radio, textfield, input, etc. [/quote] unless you keep a track of them as you're drawing them, the only way really is via JavaScript
  7. i don't think that you can use URL's when including. you need to specify the path in either of two ways: relative to the file you have the include in: include('../scripts/myscript.php'); or relative to the site: include($_SERVER['DOCUMENT_ROOT'].'/scripts/myscript.php'); paths accepted in include are the full server paths, not URL's. try it Cheers Mark
  8. [!--quoteo(post=358036:date=Mar 24 2006, 08:14 PM:name=lpxxfaintxx)--][div class=\'quotetop\']QUOTE(lpxxfaintxx @ Mar 24 2006, 08:14 PM) [snapback]358036[/snapback][/div][div class=\'quotemain\'][!--quotec--] I'm not sure, but maybe your server restricts file uploading? [/quote] i've not yet used or looked at 'copy', but have you looked at move_uploaded_file? if it's a conventional upload script via a form, then a conventional method of dealing with it may help.
  9. [!--quoteo(post=358022:date=Mar 24 2006, 07:22 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Mar 24 2006, 07:22 PM) [snapback]358022[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code] echo "<table><td width=\"what ever\" height=\"what ever\">Logged In<br><br><font color=\"red\">".$userid."</font><br></td></table>"; [/code] Sorry what did i say wrong me agin lol. [/quote] lol nothing major bad, but when the original code is simple and the question is fairly simple, showing examples of backslashing and using PHP to display HTML and inline CSS using echo can be a little overwhelming to some. just remember that some (including me sometimes) literally cut/copy and paste code you provide directly into their scripts. occasionaly a few of your posts personally have made me think and helped me decide on things, but occasionaly they, shall we say, go off on tangents as more of a coding showcase unnecessary to the original problem. but for the benefit of the tape: the code you provide draws a table with a) no table properties b) no rows (<tr>), uses backslashes on double quotes when single quotes (') are comfortable, uses the inline <font> property (dont get me started on inline styles lol) and that's about it. aside from that, none of these problems actually have anything to do with solving cookie and/or session problems. i'm very guilty sometimes of exactly the same thing, as are alot of people, so no major drama. just it's sometimes best to stick directly to the problem in hand no matter how tempting it is to write someones entire project for them. take it easy Mark
  10. to be honest, you're pretty much heading in the right direction. the only thing i'm never keen on (and this is a personal opinion, not bad practice or anything) is keeping the user logged in by cookies. you shouldn't really need a check on every page either. your login page should ideally be the only place that will determine if a user should be logged in or not. reason? if you change your login/logout methods, you only need to change one script, and it saves calling unnecessary code each time. but the steps would be: 1, check the cookies 2, if the cookies are valid, use them, set up the $_SESSION's 3, if not, go to normal login page. but on each page in your site, you only then need to check for $_SESSION to make sure user is logged in. redarrow, i've noticed this in a few of your posts. be very careful about making guesses and/or posting incorrect code, even if pseudo code, as a new user who types in: [code] echo "<table><td width="what ever" height="what ever">Logged In<br><br><font color="red">".$userid."</font><br></td></table>" [/code] will be back here with other problems faster than you can say 'uh oh'.
  11. [!--quoteo(post=358001:date=Mar 24 2006, 06:43 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Mar 24 2006, 06:43 PM) [snapback]358001[/snapback][/div][div class=\'quotemain\'][!--quotec--] A user logs in and then you have a link for the user to credit there account using a form. If your using paypal as the credt card handler use ipn to get a varable to update the database to insert a confirmation off credet. Then echo out the members credit that they have. As the user buys stuff show the user a deduation of the total from the money field. Then if the user credit gets to 0 echo a message your credit is o please credit your account. good luck. [/quote] redarrow, you've almost typed his entire question out changing a few of his phrases for more complex ones. baker_hsv youre pretty much asking in a forum designed to get specific tips how to construct an entire project. i'd suggest trying your best to implement what you can and coming back when you're stuck. if you're really serious about doing it yourself, then have a look here first: [a href=\"http://www.phpfreaks.com/tutorials/135/0.php\" target=\"_blank\"]http://www.phpfreaks.com/tutorials/135/0.php[/a] it's a spot on tutorial to break down and plan how your site will fit together.
  12. have you tried using 'unset'? [code] <?php unset($_SESSION['ERROR']); ?> [/code] it'll get rid of it as if it was never set in the first place. cheers Mark
  13. [!--quoteo(post=357955:date=Mar 24 2006, 04:23 PM:name=MentalWealth)--][div class=\'quotetop\']QUOTE(MentalWealth @ Mar 24 2006, 04:23 PM) [snapback]357955[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hi all, does anyone know what medium i can use to get data passing to and fro, from a PHP web service, to an ASP web service? eg, xmlhttp, ajax etc.......what technology can be used to talk to them both?, or what can i do to make this happen? basicly, i will be implementing a 'property' service. This service (in php) will allow browsing of property data. Other users must also be able to access and implement my data, connecting via xmlhttp (AS THEY ARE USING asp.net). I must also implement other peoples services (eg weather info service, news service etc), by connecting to their ASP services from my PHP service. so what can i use to get this to happen? ASP uses xmlhttp, but PHP uses SOAP and ajax etc........ i may be missing something, so if someone could let me know i would be much obliged. hope i explained my problem ok. regards MW [/quote] the only way i can think of to get a php and asp script to 'talk' to eachother is via URL parameters. i don't know what asp's equivalent of $_GET is though.
  14. [!--quoteo(post=357956:date=Mar 24 2006, 04:41 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 24 2006, 04:41 PM) [snapback]357956[/snapback][/div][div class=\'quotemain\'][!--quotec--] You cam use a combination of the [a href=\"http://www.php.net/strtotime\" target=\"_blank\"]strtotime[/a]() and [a href=\"http://www.php.net/date\" target=\"_blank\"]date[/a]() functions: [code]<?php $search_date = '24-03-06'; list($d,$m,$y) = explode('-',$search_date); echo date('Y-m-d',strtotime($m . '/' . $d . '/' $y)); ?>[/code] Ken [/quote] yep. if your dates will never have dates before 1/1/1970, then the way ken suggested is much easier and better. if you need dates BEFORE then, such as date of births, etc, then you need to use the function i suggested.
  15. hi 1, i can see an error with output() in your error message, but can only see a call to output_id in your script 2, where is output_id or output defined? have you included the script with 'include' ? 3, why is your php code at the bottom of your page, outside the html '<body>' tags? cheers Mark
  16. [!--quoteo(post=357940:date=Mar 24 2006, 03:12 PM:name=JamieP)--][div class=\'quotetop\']QUOTE(JamieP @ Mar 24 2006, 03:12 PM) [snapback]357940[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hi, I want to see if a string contains an email address, I know how to see if it JUST contains an email address, but I don't want that, it's for a private messaging system, and we do not allow email addresses to be sent, so I need a way to check to see if the variable containing the text contains an email address. [/quote] ok i'm sure there's a shorter pattern than this, but try: [code] $email = "this is a string with an email: hello@example.com in it"; $result = preg_match("/[A-Za-z0-9][A-Za-z0-9\.\_]*[@][A-Za-z0-9\.]*[.]([A-Za-z]{2,3})[.]?([A-Za-z]{2})?/", $email); if ($result)    echo 'email found in string'; else    echo 'no emails'; [/code]
  17. [!--quoteo(post=357933:date=Mar 24 2006, 02:31 PM:name=yourbrain)--][div class=\'quotetop\']QUOTE(yourbrain @ Mar 24 2006, 02:31 PM) [snapback]357933[/snapback][/div][div class=\'quotemain\'][!--quotec--] :( This isn't working for me. And it's supposed to be so simple. Argh. Tell me, is there a working example I can see somewhere. Or, can I give you any more info that'll help lead to the problem (other than my non-functional mind)? [/quote] what errors/results are you getting now?
  18. there's probably easier ways, but this is the way i use to convert dates to and from MySQL format: [code] function d_convert($indate,$desttype = '') {    if (($indate == '00/00/0000') || ($indate == '0000-00-00')) $indate='';    // firstly return blank field if the entry param is blank    if ($indate == '') return $indate;    // now check which way we're converting - to or from an SQL date    if ($desttype == 'SQL')    {       $arr = explode('/',$indate);       return $arr[2].'-'.str_pad($arr[1],2,'0',STR_PAD_LEFT).'-'.str_pad($arr[0],2,'0',STR_PAD_LEFT);    } else {       $arr = explode('-',$indate);       return $arr[2].'/'.$arr[1].'/'.$arr[0];    } } [/code] stick the above function wherever you normally keep functions, and use it like: convert normal date to SQL date ready to put into database: [code] $date = d_convert('24/03/2006', 'SQL'); [/code] convert an sql date to a uk dd/mm/yy: [code] $date = d_convert('2006-03-24'); [/code] been using this function myself for almost everythign i do. hope that helps
  19. [!--quoteo(post=357917:date=Mar 24 2006, 01:40 PM:name=yourbrain)--][div class=\'quotetop\']QUOTE(yourbrain @ Mar 24 2006, 01:40 PM) [snapback]357917[/snapback][/div][div class=\'quotemain\'][!--quotec--] I get this error when I try to implent that: Mixing of GROUP columns (MIN(),MAX(),COUNT()...) with no GROUP columns is illegal if there is no GROUP BY clause [/quote] whoops. try this: [code] select count(articles.id) as articlecount, categories.cat_name from articles left join categories on articles.article_category_id = categories.id GROUP BY categories.cat_name [/code]
  20. it's not $totalRows_rsCountArticles you need. all that does is return the number of records the SQL query found. [code] select count(articles.id) as articlecount, categories.cat_name from articles left join categories on articles.article_category_id = categories.id [/code] then refer to the article count as $row_rsCategories['articlecount'], not $totalRows_rsCountArticles
  21. [!--quoteo(post=357913:date=Mar 24 2006, 12:56 PM:name=brown2005)--][div class=\'quotetop\']QUOTE(brown2005 @ Mar 24 2006, 12:56 PM) [snapback]357913[/snapback][/div][div class=\'quotemain\'][!--quotec--] but i have already got the <?php ?> tags? [/quote] ahh my bad. sorry, thought it was html then noticed your quotes. just break up the echo: [code] echo"<tr> <td colspan='5'>"; include('g.php'); echo "</td> </tr>"; [/code]
  22. [code] <td colspan='5'><?php include('g.php'); ?></td> [/code]
  23. [!--quoteo(post=357902:date=Mar 24 2006, 12:17 PM:name=yourbrain)--][div class=\'quotetop\']QUOTE(yourbrain @ Mar 24 2006, 12:17 PM) [snapback]357902[/snapback][/div][div class=\'quotemain\'][!--quotec--] A few questions please... What do I put instead of [b]colname[/b]? And from which table do I select? My articles table has a column called [b]article_category_id[/b] which carries the Id of the category. The category table only has three columns (id, name, and description). Do I do an INNER JOIN? Sorry, new at this... I'm trying different this now as I wait for your reply... but I am not getting good results. So far, this is telling me that each category has 1 article in it... not correct. [/quote] colname can be any field really, but your primary key is normally the best. you select from your articles table. the above function counts the number of articles in each category. you may be able to get it all in one go with: [code] select count(articles.id), categories.cat_name from articles left join categories on articles.article_category_id = categories.id [/code]
  24. i don't think you can pass URL parameters to an include, as i think the way includes work is to pull all of the files together into one long script before PHP parses it. so if index.php was: [code] <?php echo $_GET['page']; ?> [/code] and your main.php page that includes it was: [code] <?php include('index.php?page=login'); echo 'hello world'; ?> [/code] then PHP would pull it all the bits of main.php together before parsing it: main.php: [code] <?php echo $_GET['page']; echo 'hello world'; ?> [/code] but as main.php has no URL vars, $_GET['page'] doesnt refer to anything. what you CAN do though, if you need to, is to set a variable before you include it. this will be automatically available to your include: index.php: [code] <?php echo $page; ?> [/code] main.php: [code] <?php $page = "login"; include('index.php'); ?> [/code] would make this, which would work: main.php: [code] <?php $page = "login"; echo $page; ?> [/code]
  25. [!--quoteo(post=357894:date=Mar 24 2006, 11:50 AM:name=apprentice webmaster)--][div class=\'quotetop\']QUOTE(apprentice webmaster @ Mar 24 2006, 11:50 AM) [snapback]357894[/snapback][/div][div class=\'quotemain\'][!--quotec--] thx very much Honore , but i have a question , tell me which approch is better , creating a website begining with template meaning everything is link to it , or having an application_top , applicatio_bottom and a configs.inc , so tell me which one is better guys , thx you all for the help you guys provided me , reply if you have any input thx guys [/quote] which approach is down to personal preference. i personally use a touch of both in my sites (a template for all pages that defines the layout, and includes to pull in things like my menu, nav, etc) and each page in my site has a config.php. also with my includes, i always use: [code] include_once($_SERVER['DOCUMENT_ROOT'].'/myfile.php'); [/code] for my includes and i never use ../ when refering to a file (image, another page, etc) as i prefer my pages and files to be relative to the site root rather than to other pages. this way, it doesnt matter if i shift my pages around into and out of subdirectories, they will alwys be able to find the files and links that they need.
×
×
  • 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.