PHP - Interating Script Into Site Design Help
Im trying to get a login/register script to work in my existing page design but im getting an error, i have no idea what im doing i know next to nothing about php, i just follow tutorials. Most of the error is hidden because the font is the same color as the background but is says:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/aretheyh/public_html/nealeweb.com/index.php:16) in /home/aretheyh/public_html/nealeweb.com/index.php on line 25 Heres the page link where the error occurs: http://www.nealeweb.com/index.php Please help, im useless! Similar TutorialsHello I am looking to redesign an old poll system what approved to work effeciantly, however I now need to get the poll to work on my new site. I am getting these errors. Warning: mysql_query() [function.mysql-query]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/gaogier/public_html/includes/polls.php on line 4 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/gaogier/public_html/includes/polls.php on line 4 Warning: mysql_query() [function.mysql-query]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/gaogier/public_html/includes/polls.php on line 52 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/gaogier/public_html/includes/polls.php on line 52 Code is on pastebin - 24 hours. http://pastebin.com/1u19Xwwk Now here is where my files are located includes/connect.php includes/polls.php pages/ - my pages.php - displayed as a new folder almost using mod rewrite. tpl/sidebar.tpl - where my poll will be displayed using php - include. I was wondering if anyone is aware of a php script that can pull html from a external site and create a local page with all the urls and image paths rewritten to local paths. I'm trying to create a module for Drupal that does this. Any script already written that I can adapt to Drupal would be great. If no one is aware of a current script that does this, can anyone point me in the right direction? Hello, Ive got a fairly successful website and im looking at cloning it, I want to set up a cron to check the main site if there are any new posts and if there are insert it into the DB. Ive got them on 2 separate hosts so i don't want to just read from the DB increase the main site goes down and brings the whole 2nd site down. What would be the easiest way to do it? Not looking for people to give code, Just their suggestions. Cheers Hey all. I've created a script that updates a website's config in a database. The script itself works fine but I feel it is rather uncanny. Where can I look to find better methods of achieving what I'm trying to accomplish? Here's my script that updates my table with columns id, showlogin, colorscheme, blogmenu, aboutus. I explain the script below it. if (isset($_POST['submit'])) { // id will always be 1 and only query if only submit was pressed $sql = "UPDATE config SET id=1"; // showlogin values are 1 for show login form and 2 for don't if(!empty($_POST['showlogin'])) { $showlogin = $_POST['showlogin']; $sql .= ", showlogin='$showlogin'"; } if(!empty($_POST['colorscheme'])) { $colorscheme = $_POST['colorscheme']; $sql .= ", colorscheme='$colorscheme'"; } if(!empty($_POST['blogmenu'])) { $blogmenu = $_POST['blogmenu']; $sql .= ", blogmenu='$blogmenu'"; } else { $sql .= ", blogmenu=2"; } if(!empty($_POST['aboutus'])) { $aboutus = $_POST['aboutus']; $sql .= ", aboutus='$aboutus'"; } else { $sql .= ", aboutus=2"; } mysql_query($sql, $connect) or die (mysql_error()); } It works like this. I have a form with a few selects and checkboxes. The selects are the colorscheme and showlogin. The checkboxes are blogmenu and about us, both defaulting to the number 2 if they are not checked. 1 means show this item on the live site and 2 means do not show. This is pulled out of the database on page loads. So, I hope I was clear as my mind is spaghetti right now. Cheers! I have approximately 2,300 videos embedded on my site, and I am constantly adding more. The videos are hosted by YouTube. When a video is deleted from YouTube, it becomes unavailable on my site. Each video's ID is in my MySQL database. A video ID looks like this: ZFOuxAx-dkc I need a script that will do the following: select the IDs from my database check if the videos are still available on YouTube create a list of the videos that are unavailable. If possible, it would be great if the script could also tell me if any of the videos have been blocked in certain countries. The script has to be fully commented so that I can understand it. I want to run the script manually every few days. I don't want to have to change my database tables. I've been told that you can use YouTube's API or YouTube's oEmbed interface. I've also been told that, because there are so many videos, you will have to use cURL multi handles. If interested in this project, please PM me your price. This is an urgent project. I have placed ads elsewhere. I wrote this basic script yesterday to process and generate a Google Site Map. And it works! BUT I want to advance this script to accommodate for something else and I don't know the correct path to take from here, but I will tell you what I've found out so far.. Current Situation: 1 - Currently my below script generates urls in the site map like: http://abcdefg.com/index.php?dispatch=products.view&product_id=29826 2 - I have .htaccess configured to rewrite the urls to the products name data like: http://abcdefg.com/pennies/wheat-pennies/lincoln-wheat-penny-cent.html (just an example) and these urls are ONLY active if clicking on the site links themselves - meaning if I enter: http://abcdefg.com/index.php?dispatch=products.view&product_id=29826 directly into the url, the url does not resolve to this natural friendly url name. What Id like to achieve (which I don't know what direction I should be looking!): - I'd like my xml output urls (as current) to be written in the natural format (as in #2 above). FYI here is a current example output item in my sitemap: Code: [Select] <url> <loc>http://abcdefg.com/index.php?dispatch=products.view&product_id=29803</loc> <changefreq>weekly</changefreq> <lastmod>2010-09-24T08:00:00+04:00</lastmod> </url> Can anyone give me some guidance on what method might work for this? Do you think it's more a mod_rewrite issue? Or can this be handled easier with straight up modifications to my below? I'm just a bit confused on what direction I should be looking.. Thanks for any input. <?php header("Content-Type: text/xml;charset=iso-8859-1"); echo '<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; //include('config.local.php'); $cxn = mysqli_connect($config['db_host'], $config['db_user'], $config['db_password'], $config['db_name']); $query = "SELECT cscart_product_descriptions.product_id, cscart_products.product_id, cscart_products.timestamp FROM cscart_product_descriptions JOIN cscart_products ON cscart_product_descriptions.product_id = cscart_products.product_id WHERE cscart_products.status='A' LIMIT 10000"; $result = mysqli_query($cxn, $query); $row = mysqli_fetch_array($result); while ($row = mysqli_fetch_array($result)) { $formatedTime = $row['timestamp']; echo '<url> <loc>http://abcdefg.com/index.php?dispatch=products.view&product_id=' . $row['product_id'] . '</loc> <changefreq>weekly</changefreq> <lastmod>'. date('c',$formatedTime) .'</lastmod> </url>'; } //while ($row = mysqli_fetch_array($result)) echo '</urlset>'; ?> Nothing fancy, I am just looking for a simple php script that would check a text file on my server that has a bunch of domains in it. I want the script to ping a random 5 or 10 sites in the list, and then redirects the visitor to the fastest one, or at least one that responds, and is not down. If all that are checked are down, then it would need to recheck the list. I want it to pick random domains out of the list, as I don't want users directed to the same site(s) all the time, just because it pings the best. When I say ping, I am talking about making sure the user isn't directed to a website that is down, or a slow loading website. I am not sure if "ping" is the correct word for that tho? Can anybody offer me code like this for free, or is this type of request getting into something that would need to be paid code? (and if so, any idea how much? I didn't post this in the freelancing forum, because it sounds like it might be something simple to code. I am not a coder, so I am looking for something complete that I can add to a php file and it works. Thanks for any code, pointers/problems with this idea, or price quotes (if necessary) on this little script I am looking for. I have several "sites" located in my html directory, and each has a "general" access point and an "administrator" access point:
/var/www/html/site1/index.php /var/www/html/site1/administrator/index.php /var/www/html/site2/index.php /var/www/html/site2/administrator/index.php /var/www/html/site3/index.php /var/www/html/site3/administrator/index.phpAll sites are similar except that data will be specific to site1, site2, or site3, etc. Users who log onto /var/www/html/siteX/index.php are totally unrelated to those who logon to /var/www/html/siteX/administrator/index.php, will have different logon credentials, are stored in different DB tables, and each should have their own session. If a user logs off of either the general or administrator site, it should not effect the other site even if they were previously logged on to both on the same PC (and of course not effect other sites). When a user logs off, I would like to destroy their previous cookie and associated session. Users for either will only use https. I am using Apache to rewrite https://www.mysite.com/ to https://mysite.com/. While I named the administrator site "administrator" above, the administrator user has the ability to change the directory name. I am thinking I need to use session_set_cookie_params to specify where I wish the session cookie to be stored since /var/www/html/siteX/administrator/index.php is a sub-directory to /var/www/html/siteX/index.php, but am not really sure. Sorry for the cryptic post, but I am not very well versed in this subject. How would you recommend setting up cookies/sessions for this scenario? Thank you now i use this code to show where the visitors came from to my site. <?php $referer=$_SERVER['HTTP_REFERER']; echo $referer; ?> now, i want to show the 5 latest vistors referer's site url on my site ? Not sure if I'm trying to achieve something totally crazy here, or if this is something pretty standard. Didn't have much luck with searching as I'm not fully down with all the terms. (A) I have one site providing an RSS feed. (B) I have one site I want to search, once for each of the items in the feed A. (C) I want the results of the search in (B) to be displayed on page (C). So for example, the feed on (A) says; apples bananas oranges cheese I want site (B) to search for each of those terms (by passing the item in the feed (A) to the ?search= part of the URL of that page) and then show the results from THAT search on page C. Bit of a complex one, let me know if you need me to clarify. Thanks for any help! Hi, My first post here is a cry for help I have a Windows 2003 server running IIS6/PHP5, the server hosts multiple web sites. The problem is include files that are for site A are showing on site B (each site having its own includes as part of the site files in its own site folder), though not every time, its very random, sometimes the correct includes show, sometimes ones from another site on the same server. This only occurs where the include files for both sites have the same name, such as 'inc-header.php' for example. I can only assume PHP is caching includes and because they have the same name is showing the wrong one on other sites sometimes, if I rename them to something unique then the problem goes away, but its not a practical solution to rename all include files to unique names so I find myself looking for a 'real' fix. I have a feeling its to do with the include_path in the php.ini, but right now its disabled with a semi-colon, and I don't want to set one as I have no global includes, all includes are site specific. Any help would be very much appreciated! Phil Transferring data from sub-domain.site.com Reading sub-domain.site.com What is this all about? I'm going to put all .. images into a separate sub-domain eg: images.site.com. This would create a folder inside my public_HTML called "images" Now when sites have that Transferring data, and Reading... is this .. something relating to what I want. Facebook also does it, and they get their images for the site from a sub domain, how is it all done? I'm not sure if its entirely PHP, but I hope someone can help. Thanks I'm currently running a classified ads site and planning to display my own content from database combined with and external site rss. So here is what i got right now after the db query for the jobs ads (procedural php),
while ($row = mysqli_fetch_array($results, MYSQLI_ASSOC)){ echo '<div class="media margin-none"> <a class="pull-left bg-inverse innerAll text-center" href="#"><img src="'.$foto.'" share_alt="" width="100" height="100"></a> <div class="media-body innerAll"> <h4 class="media-heading innerT"> <a href="' . $row['title'] .'-da' . $row['id_ad'] . '" class="text-inverse">'. $remuneracion .' ' . substr(ucfirst(strtolower($row['title'])), 0, 53) . '</a> <small class="pull-right label label-default"><i class="fa fa-fw fa-calendar-o"></i> ' . $row['date_created'] . '</small></h4> <p>' . substr(ucfirst(strtolower($row['description'])), 0, 80) . ' ...</p>'; echo '</div> </div> <div class="col-separator-h"></div>'; } echo pagination($statement,$per_page,$page, $url_filtros, $filtros); ?>it is the while loop that i use to display ads from my database, what could be the best way to display (in this same loop?) other site's rss feed so i can show my content combined with the external rss? Thanks Hi I made a new design for my website and I made some changes. I want to use layout for my second site.
I'll like to know if my site is easier to browse through now and if you like the design better?. I test my site on internet explorer, chrome, and firefox. It is best to use site on better browsers like firefox and chrome to get a better experience of site. Thanks.
http://adjade.com
Hi guys, I don't know if I'm over complicating things here and cannot see the wood for the trees, but I seem to have got myself confused. What I'm simply trying to do is get teamName and teamresults of a team from a database. The code will perhaps explain better than I can (note I haven't included the DB class which is fine).
class TeamCollection { protected $database; protected $teamid; protected $team_name; // pass db by dependency injection... public function __construct(Database $database) { $this->database = $database; } public function getTeam($teamid){ $this->team_id = $teamid; $this->database->query("SELECT team_name, nickname, founded FROM club WHERE team_id=:teamid"); $this->database->bind(':teamid', $this->team_id); // spawn a new Team object if query is valid, if not throw exception and end via try/catch... if ($result = $this->database->single()) { return new Team($result); // create new Team passing $result to Team constructor } else { throw new exception ('No Valid Team returned'); } } public function getResults($teamid){ $this->team_id = $teamid; $this->database->query("SELECT result FROM results WHERE team_id=:teamid"); $this->database->bind(':teamid', $this->team_id); // If a Team has valid results, return array of match scores.. if ($scores = $this->database->results()) { return $scores; } else { throw new exception ('No Valid Team Results to return'); } } } //end class // Team is abstracted from DB class Team { private $team_name; private $result; private $scores; public function __construct(array $result) { $this->team_name = $result['team_name']; } public function getName() { $this->team_name; } public function getResults(array $scores) { foreach ($scores as $row){ echo $row; } } } // implementation $team_id =9; // passed variable.. $database = new Database($server,$db_type); // create db.. $database->connect(); // connect to db.. $collection = new TeamCollection($database); // pass live DB link to TeamCollection Class try { $team = $collection->getTeam($team_id); // try and spawn a valid Team Object.. echo $name = $team->getName(); // If so lets return a Team name $scores = $team->getResults($team_id); // Now try and get Team Results.. $display_results = $scores->getResults($scores); // Display results by passing them to Team class to } catch (Exception $e) { Echo 'Exception Thrown: ' . $e->getMessage(); }My basic difficulty is where to put the getResults method and how to use it? I'm fine spawning a new Team as required, but is my logic for then moving on to getResults sound? I was trying to abstract my Team class from having any database association at all. Is this a wise approach or just not required? Am I overcomplicating the issue or missing something? Can anyone help? I guess my difficulty is between connecting classes and objects in the best manner. Thanks in advance. Edited by mich2004, 19 May 2014 - 06:48 AM. Hi All, I currently have a ticketqueue that show's all tickets assigned to a group of people, but split into personal queues, but the way that I wrote it, means that it needs manually updating if a specific person leaves/joins the department. For example, to get the queue details, I use the following query: Code: [Select] $username1 = mssql_query("select id,subject,body,priority from queue where assignedto = username1";) $username2 = mssql_query("select id,subject,body,priority from queue where assignedto = username2";) I have repeated this code for all of the users in our team. Which seams a waste, as I have all the information on our team stored in a DB called "sysadminusers". Is there an array I could use that would look at all the usernames in the table, and then repeat the query for me? I would also need this array to display the results on the page, currently I use the following: Code: [Select] while($username1_tickets = mssql_fetch_assoc($username1)){ echo $username1_tickets['id'],$username1_tickets['subject']$username1_tickets['body'],$username1_tickets['priority'];} while($username2_tickets = mssql_fetch_assoc($username2)){ echo $username2_tickets['id'],$username2_tickets['subject']$username2_tickets['body'],$username2_tickets['priority'];} I am just looking for some design advice and code examples that would help me tidy up my code for this page, it seams a lot of code for quite a simple page. Thanks Matt Okay, not sure what exactly I need but I need to store data in a MySQL database. The financial data for each user has to be stored for each day. I.e. User 1 has 20 financial data columns say (rent, maintenance, wages, shopping... etc). I need to store each of those separately so they can be displayed in a report. There is more than one user. Most likely a couple of hundred users although it needs to work for up to a few thousand users. Also, each user's daily financial data has to be stored against the date of that data so the user can see the change in finances between day X and day Y for example. So far my best idea has been to create a table for each user and then in that table store the financial data in the columns against the date as the primary key. Does anyone have a better way for this or should I do this? Hello I have a question in regards to design. No need for example code just of how to approach the problem. Issues and things that cannot change because they are part of the situation. 1. Cannot use any database like oracle, MySQL, or SQLite 2. The server does not run PHP5 3. The students do not have a unique field and cant have one because they have not my employers have not decided on one. Here is the problem: I have to make a form with the following fields first name last name comments date I have stored the fields in a text file. However, how can I relate date to the comment without having duplicates records? For example. Lets suppose my boss asked me can you look up the comments that the counselor made in july 10 2010. My answer: One must have duplicate records of each instance of a comment. Am I wrong? Hi, For the last few years on my website I have been using FluxBB/PunBB's login script which basically just stores a cookie with their user ID and their password hash. This is fine except if the database got leaked anyone can login as anyone else providing they have their hash. I'm trying to be more secure about this now. Can someone explain a better process to me please? I was thinking of storing sessions with a unique hash in an 'active_sessions' table and providing they have a cookie with that hash they are granted that session? If someone uses a different IP to what that session was created with it's deleted? I'm new to all of this so any advice would be great. I want this to be secure. |