Jump to content

ChemicalBliss

Members
  • Posts

    719
  • Joined

  • Last visited

    Never

Everything posted by ChemicalBliss

  1. I see your predicament, unfortunately these are the things that teach you in life to be extremely cautious of what you purchase and who you purchase it from. A lot of people that hardly know anything about PHP can smash together a simple script thats supposed to do something and sell it and it goes for many products in life . As for fixing your code i see you probably dont know much and in these instances for really comlpicated code it is usually having to find a friend who can help you out or finding a cheap freelancer to clean up the code somewhat - and that can be risky as well. Have you tried to remove the offending line? Try this: (Ive removed that last endif; and i have also converted the textual statements to curly braces.. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <!-- Title --> <title><?php wp_title('«', true, 'right'); ?><?php bloginfo('name'); ?></title> <!-- Content Type --> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> <!-- Link REL / CSS --> <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" /> <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" /> <link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" /> <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> <!-- Default Style --> <?php if($_COOKIE['style'] == 'style-light'){ ?> <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/style-light.css" /> <?php }else{ ?> <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/style-dark.css" /> <?php } ?> <!-- Light / Dark CSS --> <link rel="alternate stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/style-light.css" title="style-light" media="screen" /> <link rel="alternate stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/style-dark.css" title="style-dark" media="screen" /> <?php if ( is_singular() ){ wp_enqueue_script( 'comment-reply' ); } ?> <?php wp_head(); ?> <!-- Javascript --> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/common.js"></script> </head> <body> <!-- Top --> <a name="top" id="top"></a> <div class="topbg"></div> <!-- Wrapper // --> <div class="wrapper"> <!-- Header // --> <div class="header"> <!-- Logo --> <h1><a href="<?php echo get_option('home'); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/img/logo-trans.png" alt="GameNow WP Theme" /></a></h1> <!-- Top Links // --> <ul class="toplinks"> <li><img src="<?php bloginfo('stylesheet_directory'); ?>/img/icon_rss-trans.png" alt="#" /><a href="<?php bloginfo('rss2_url'); ?>">Subscribe</a></li> <li><img src="<?php bloginfo('stylesheet_directory'); ?>/img/icon_bookmark-trans.png" alt="#" /><a href="javascript:bookmark('<?php echo get_option('home'); ?>','<?php echo str_replace("'","\'",get_bloginfo('name')); ?>');">Bookmark</a></li> <li><img src="<?php bloginfo('stylesheet_directory'); ?>/img/icon_twitter-trans.png" alt="" /><a href="http://www.twitter.com/<?php echo get_wpn_config('twitter_username'); ?>">Twitter</a></li> </ul> <!-- // Top Links --> <!-- Search // --> <div class="search"> <form id="searchform" action="<?php echo get_option('home') ?>" /> <input type="text" name="s" value="Site Search..." onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" /> <input type="image" src="<?php bloginfo('stylesheet_directory'); ?>/img/spacer.gif" /> </form> </div> <!-- // Search --> <!-- Buttons --> <a class="button button-dark styleswitch" rel="style-dark" href="#">Dark</a> <a class="button button-light styleswitch" rel="style-light" href="#">Light</a> <!-- Menu // --> <ul class="menu"> <li><a href="<?php echo get_option('home'); ?>">Home</a></li> <?php wp_list_pages('sort_column=menu_order&title_li=&depth=0&include='.get_wpn_config('menu_include').'&exclude_tree='.get_wpn_config('menu_exclude')); ?> </ul> <!-- // Menu --> <!-- Submenu // --> <ul class="submenu"> <?php wp_list_categories('sort_column=menu_order&title_li=&depth=0&show_count=0&include='.get_wpn_config('submenu_include').'&exclude='.get_wpn_config('submenu_exclude')); ?> </ul> <!-- // Submenu --> </div> <!-- // Header --> <?php if(is_home() && !get_query_var('paged')){ ?> <!-- Featured / Top Articles // --> <div class="ftop"> <div class="featured"> <div class="fthumbs"> <?php $i = 0; $featured = new WP_Query("cat=".get_wpn_config('featured_category_id')."&showposts=5"); while($featured->have_posts()){ $featured->the_post();?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" alt="" <?php if($i == 0){ echo 'class="active" '; } ?>/></a><br /> <?php $i++; } $i = 0; ?> </div> <div class="fwrap"> <ul> <?php $featured = new WP_Query("cat=".get_wpn_config('featured_category_id')."&showposts=5"); while($featured->have_posts()){ $featured->the_post();?> <li> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><img src="<?php echo get_post_meta($post->ID, "featured_thumbnail", true); ?>" width="630" height="230" /> <div> <a class="title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br /> <?php wpn_content_limit(get_the_content(),90); ?> <a href="<?php the_permalink(); ?>">more</a> </div> </li> <?php } ?> </ul> </div> </div> <div class="top"> <span class="heading1"><span>Top Articles</span></span> <ul> <?php $sql = " SELECT * FROM $wpdb->posts WHERE post_date_gmt > ".(time()-strtotime('-2 weeks'))." AND post_type = 'post' ORDER BY comment_count DESC LIMIT 5 "; $top_posts = $wpdb->get_results($sql); foreach ($top_posts as $post) { ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><span><a class="comments" href="<?php the_permalink(); ?>#comments"><?php echo $post->comment_count; ?> Comments</a>Posted Under: <?php the_category(', '); ?></span></li> <? } ?> </ul> </div> <div class="clear"></div> </div> <!-- // Featured / Top Articles --> <!-- Content // --> <div class="content"> <!--[if lt IE 7]> <div style='border: 1px solid #F7941D; background: #FEEFDA; text-align: center; clear: both; height: 75px; position: relative;'> <div style='position: absolute; right: 3px; top: 3px; font-family: courier new; font-weight: bold;'><a href='#' onclick='javascript:this.parentNode.parentNode.style.display="none"; return false;'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-cornerx.jpg' style='border: none;' alt='Close this notice'/></a></div> <div style='width: 640px; margin: 0 auto; text-align: left; padding: 0; overflow: hidden; color: black;'> <div style='width: 75px; float: left;'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-warning.jpg' alt='Warning!'/></div> <div style='width: 275px; float: left; font-family: Arial, sans-serif;'> <div style='font-size: 14px; font-weight: bold; margin-top: 12px;'>You are using an outdated browser</div> <div style='font-size: 12px; margin-top: 6px; line-height: 12px;'>For a better experience using this site, please upgrade to a modern web browser.</div> </div> <div style='width: 75px; float: left;'><a href='http://www.firefox.com' target='_blank'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-firefox.jpg' style='border: none;' alt='Get Firefox 3.5'/></a></div> <div style='width: 75px; float: left;'><a href='http://www.browserforthebetter.com/download.html' target='_blank'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-ie8.jpg' style='border: none;' alt='Get Internet Explorer 8'/></a></div> <div style='width: 73px; float: left;'><a href='http://www.apple.com/safari/download/' target='_blank'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-safari.jpg' style='border: none;' alt='Get Safari 4'/></a></div> <div style='float: left;'><a href='http://www.google.com/chrome' target='_blank'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-chrome.jpg' style='border: none;' alt='Get Google Chrome'/></a></div> </div> </div> <![endif]--> hope this helps
  2. There is nothing wrong with that code it wil work on any version of PHP; <?php include("inc/menu.php");?> Are you sure the folder/file exists? What errors are you getting? If an update to your host caused this i would contact them in case they know of any on-going problems with the upgrade. hope this helps
  3. It's deprecated because PHP does this automatically now. Call-Time Pass by reference. Your passing a reference to a function. In the new PHP they realised instead of letting people specifically pass a reference to a function, the function should specify whether its arguments should be passed-by-reference. (Cuts down argument discrepencies and makes code a little easier to read). So, remove any & when calling a fnuction. and on the function itself add an & in front of the arguments you want to be referenced. eg: function somefunc($arg1, &$ref1, $arg2) $ref1 will be a reference. hope this helps.
  4. No offense but that is some seriously messy code. Impossible to follow. <?php endif; ?> That is your offending line but good luck fixing if removing it breaks your application :S. You need to read some guides on abstraction, code readability and best practices. You shouldnt mix HTML with PHP in such a way.
  5. There are many GUI/WYSIWYG applications for PHP, but to be honest if you dont know a LOT about PHP code itself then you will get stuck at some point and wont know where to fix (or how). PHP in your head should go something like this: Think of design (purpose of application) Create basic file structure (how and where files will be placed) Get some classes that people have laready made that can save you a lot of time. Write your code using those classes. Classes are really the only thing i can see saving you time and effort effectively. But some WYSIWYGS can be pretty good they can tell you syntax errors and even some logic errors as you type. Google search WYSIWYG PHP editor, or GUI php editor. hope this helps
  6. Ok i think your logic is wrong. I personally would use MySQL to only fetch the data for the city i am viewing. Do this by adding a condition statement in the WHERE clause of your query: We also need more information, like the database layout, and what is visibility condn etc, anyway rnu this code and tell us what it spits out (view source): $country_adcounts = array(); $city_adcounts = array(); $sql = "SELECT *, COUNT(*) as adcnt FROM $t_ads a INNER JOIN $t_cities ct ON ct.cityid = a.cityid AND ($visibility_condn) INNER JOIN $t_countries c ON ct.countryid = c.countryid WHERE ct.enabled = '1' AND c.enabled = '1' GROUP BY ct.cityid"; $res = mysql_query($sql) or die(mysql_error().$sql); echo(":DEBUG: Query; ", $sql, "\n"); // debug while($row=mysql_fetch_array($res)) { print_r($row); // debug echo('$row['.$row['id'].']', print_r($row, true)); $country_adcounts[$row['countryid']] += $row['adcnt']; $city_adcounts[$row['cityid']] += $row['adcnt']; } echo('$country_adcounts = ', print_r($country_adcounts, true)); // debug echo('$city_adcounts = ', print_r($city_adcounts, true)); // debug echo('$city = ', print_r($city, true)); // debug echo('$visibility_condn', print_r($visibility_condn, true)); // debug echo('Number of Matching Rows: ', mysql_num_rows($res)); // debug exit(); // debug $adcount = 0+$city_adcounts[$city['cityid']];
  7. Then you will need to split the variable itnto its different parts. Can you confirm that this is what you get (Exactly)? /thename=First+Last name and not /?thename=First+Last name
  8. then since your making the variable _knowing_ that it is going to be used in a url (since it is formated for a header request), the values should be urlencoded() at the point of the strings creation.
  9. Consistency error: $row['adcnt'] is not the same as $adcount - pick one variable name, I would suggest $adcount as the $row array is updated on every loop. hope this helps
  10. you could use a php script to remove any and all comments (and even compress your code) for a production environment. Keep your original source code in case you want to change/add/remove or play with something in the code.
  11. So it would seem your javascript is not workign properly, do you get any errors from the java console in your browser? (firefox is Awesome for developers of java!). use the javascript: alert() to help debug your code like so: function getFile (url) { var url = "AJAX/get_Bank.php?dealType="+ this.value; alert("getFile( " + url + " );"); if (window.XMLHttpRequest) {xmlhttp=new XMLHttpRequest();} else {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");} xmlhttp.open("GET",url,false); xmlhttp.send(); // a loop that looks through all <div>s on the page // and then replaces the id with the value and gets that file var divs = document.getElementsByTagName("div"); for (var i=0; i<divs.length; i++) { if(divs[i].id == "bank") { alert("(divs[i].id == bank - response text: " + xmlhttp.responseText); divs[i].id = this.value; divs[i].innerHTML=xmlhttp.responseText; } } } I believe your missing some javascript required for the AJAX functions to work.
  12. You need to use concatenation, but also the variable should only be the actual value of the get request item; $name = $_GET['thename']; // gets First+Last name $to = "some@email.com"; $subject = "Subject of Email"; $message = "Click this link: http://mysite.com?/thename=".urlencode($name); hope this helps
  13. You really should use the full php tags (<?php) - but thats completely unrelated, anywho; get_Bank.php <? if ($_GET['dealType'] == "AL") { $bank = ' <fieldset id="AL"> <legend>Auto Loan Figures</legend> <ul> <li><label for="price">Price</label><input type="text" name="price" id="price" class="price" size="7" onchange="currency(this)"></li> <li><label for="down">Down</label><input type="text" name="down" id="down" class="price" size="6" onchange="currency(this)"></li> <li><label for="tax">Tax</label><input type="text" name="tax" id="tax" class="price" size="6" onchange="currency(this)"></li> <li><label for="reg">Plates</label><input type="text" name="reg" id="reg" class="price" size="4" onchange="currency(this)"></li> <li><label for="gap">Gap</label><input type="text" name="gap" id="gap" class="price" size="4" onchange="currency(this)"></li> </ul> <ul> <li> <label for="pymtNum">--------------- Payment ---------------</label> <input type="text" name="pymtNum" id="pymtNum" size="3" maxlength="3" onkeyup="return autoTab(this, 3, event)"> @ <input type="text" name="pymtAmnt" id="pymtAmnt" class="price" size="5" onchange="currency(this)"> per <select name="pymtType"> <option value="Weekly" selected="selected">Week</option> <option value="Monthly">Month</option> </select> </li> <li><label for="APR">APR</label><input type="text" name="APR" id="APR" class="rate" size="6" value="19.00"></li> </ul> </fieldset> '; } elseif ($_GET['dealType'] == "CAC") { $bank = ' Credit Acceptance stuff goes here '; } else { $bank = 'You must choose a bank before continuing'; } // the javascript needs to be able to get the result echo $bank; ?> I'm not sure if your javascript is sound as im not as fluent in javascript . Looking at some tutorials im sure you can check that too . hope this helps
  14. You will need to review this page very closely: http://www.php.net/manual/en/migration5.incompatible.php good luck
  15. My bad, these last few lines should be: $output = curl_exec($curl_handle); $info = curl_getinfo($curl_handle); curl_close($curl_handle); echo "<!--// Look in page-source (html) to view this properly: \n", print_r($info, true), "\n //-->\n", $output; hope this helps
  16. $id should be as it is above on this line: echo "<td><center>" . $row['id'] . "</center></td>"; eg, echo "<td><a href=\"../valdymas/edit.php?topic=\"".$row['id']."\">" . $row['name'] . "</a></td>"; hope this helps
  17. Make sure the temp folder exists. Also, this should be enough to get cookies working: $tmpfname = "temp\cookie.txt"; $curl_handle=curl_init(); $user_agent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0)"; curl_setopt($curl_handle,CURLOPT_URL,'url goes here'); curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1); curl_setopt ($curl_handle, CURLOPT_COOKIEJAR, $tmpfname); curl_setopt ($curl_handle, CURLOPT_COOKIEFILE, $tmpfname); $output = curl_exec($curl_handle); $info = curl_close($curl_handle); echo "<!--// Look in page-source (html) to view this properly: \n", print_r($info), "\n //-->\n", $output; As AbraCadaver stated, you should fix your consistency errors (variables names should stay the same for ex): curl_setopt ($curl_handle, CURLOPT_COOKIEJAR, $tmphandle); curl_setopt ($curl_handle, CURLOPT_COOKIEFILE, $tmphandle); Should be: curl_setopt ($curl_handle, CURLOPT_COOKIEJAR, $tmpfname); curl_setopt ($curl_handle, CURLOPT_COOKIEFILE, $tmpfname); And use integer boolean values (0,1) instead of string boolean (true,false) when defining cURL Options. For example: curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1); hope this helps
  18. Just to let you know, the PHP equivalents of the ASP code you posted is as follows: a_login_check.PHP <?php if (!isset($_SESSION["admin_user_name"])){ Header("location: login.php"); } ?> Protected-Page.PHP <?php include("include/a_check_login.PHP"); ?> <html> ... CONTENT ... </html> There are many "best-practices" to follow but i would reccomend reading over a couple "PHP Security" guides/tutorials . hope this helps.
  19. I would personally use two "views", 1) Would show a calendar for a given month, it looks nice and can be clickable, with events listed in each box for that day, if you have space you could put the time range as well. 2) Day View, this would list every event in as much detail as possible for the given date/day. The admin/management part would imo be a simple admin login, which would show extra buttons normal users cannot see. These buttons; Add/Remove/Edit The Add is very simple, you create the form in pure html, then use a simple insert script to sanitize (make safe) the user input and insert the new row into mysql. The Remove is relatively easy but slightly more complex; it will be a simpel script that will take a number (id) of a row and check if it exists. If it exists then you can display a "confirmation page" to the user, are you sure you want to delete ..... When/if the user clicks yes then it will simply DELETE FROM the row. The Edit is the most complex, first it selects the data for the given row you want to edit. Then it shows a form with all the values already filled in. Then when you click submit it will go to a small script that will "update" the mysql row given. The hardest part to code will be the actual calendar, being dynamic, i would suggest trying to follow a tutorial found from google and then modify it to your needs. I would _not_ just copy/paste and modify because you wont have a clue how it works. IMO first step is to build the calendar view. (a "View" is a term used to describe a page or object the user sees in respect to the program/project). hope this helps
  20. Take a look at what you just said . You want the exact functionality of echo "<option ".($pageName == 'Home') ? 'selected="selected"' : ''.">Home</option>"; But you need the condition to be dynamic, very simple again, change the "hard-coded" value into a variable like so: echo "<option ".($pageName == $row["menuName"]) ? 'selected="selected"' : ''.">Home</option>"; As mjdamato stated; a) $pageName wil have to be set (Where are you getting the current page from, or the page you want to be the default - is it a config setting?). b) It is easier to read to not use an echo straight away but to use a variable or array as he has done in his example. hope this helps
  21. Congrats, I would highly reccommend database for scalability (adding to your current project). It will save a lot of effort . Also, since this problem is resolved at the bottom of this page is a "Mark Resolved" or similar button, feel free to click that
  22. I would suggest against reinventing the wheel per say but basically you would use a "recursive function", ie a function that calls itself. This function would take a single argument, a webpage URL. it would return true or false (depending if there are any more links to follow). The function would grab the URL (page), scan it for links, then loop through each link calling itself. It would also save whatever data you want to save (with the url) and the page title in an array - most likely a global array to make things easy. At the end you would have an array something like: array( "http://www.somedomain.com/somepagephp" => array( "title"=>"Some Page!", "keywords"=>"Some content from the page...as the penguin dropped the peanut...etc" ) I would also use another global array containing a simple list of links already scanned, so it doesnt endlessly loop. hope this helps
  23. You want to turn that inline statement into a variable you can manipulate or echo at will? Very simple; First we move the echo to the front (as you have done). Remove any php tags (which you have done). Then what you made the mistake with was the "concatenation", ie, joining two variables or strings together. All we do is find any code that seems dynamic, like the "Ternary Conditional" that tests if pagename is equal to "home": Generally, "Ternary conditionals" are written like this: $var = ($condition)? true : false; So putting this into an echo statement: echo "<option ".($pageName == 'Home') ? 'selected="selected"' : ''.">Home</option> hope this helps
  24. Yes it will be handy to know which characters it is displaying. you say you have checked the encodings, can you tell us what encoding your (trying) to use in php, and what encoding the mysql table is under. Also, try a new test script that just selects some rows, it is possible there is a bug in your code or even a bug in the PHP installation itself, if other test code throws the same junk data then it could be your mysql extension for PHP, or some other misconfiguration. If the test code does not throw any junk data then more than likely there is some bug in your code that you will have to track down. Are you echoing the query, and the result, as soon as you query mysql?
  25. Do you even list the users that are in the chat? If not, i would suggest doing so by creating a seperate flat-file used to store usernames with a timestamp of their last activity on each line. Something like: someuser141::1296501723 This would be relatively easy to go through and put the users into an array which you can echo out. And also check their activity at the same time (for timeouts). To get a timestamp in php use the time() function. Once you get this working then you should work on truncating since you can then nkow how many people are in the chat. You could even save the chat to a log file once all the users have left. hope this helps
×
×
  • 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.