PHP - The Best Php Start
Hello everyone,
I have started PHP not so long ago and I must admit that this whole world is quite confusing. On the internet, we can find everything... A link saying that we should press A and not B, another saying that A must not be pressed and B shoud etc. When looking on the web to learn about PHP, I often find myself more confused at the end of the day than at the beginning of the day. So I would like to know, with all you've learned in the past years, what would be the best advice you could give to a newbie who's been assigned on a big project and who wants to learn PHP properly ? Would you tell him to use a templating system ? Would you tell him to use a PHP framework ? Would you tell him to use a caching system to store some data ? What else should be taken in consideration ? PS: Flexibility is a must for this project Thanks ! Similar TutorialsOn my website I currently have it set up so that each user can pick there "avatar" (little picture or icon) Each user has the same choices but they all can pick different ones. I want to make it where they can upload their own picture and have a custom avatar. Where Should I start? ive been looking around and every tutorial information i get is to show data in two fields linked now my problem is i have a table with multiple fields adnd need to show it in one list to give you an idea of what im talking about
Table is like this
Winner 2nd place 3rd place 3rd place2
player a player b player c player d
player h player f player e player g
now what i need to know what to look for is to get it so that the list would be like this
Player a
player b
player c
player d
player e
player f
player g
player h
looking for something to work from any help on what in php i should look for to accomplish this i would be greatly appreciated
Sometimes my mailserver craps out and I need to restart it. Since RDP is blocked at my current company, I was hoping to simply make a button on a password protected webpage to start it. This would be a simple button and no user config so as to reduce security risk (hopefully). I need to do something like: echo exec('net start abc'); This works if I use 'whoami' or 'hostname', but not with the 'net' command. Also, the whoami shows the following: nt authority\network service This is using IIS/WIN2003 Hi All. I am new to PHP, but am learning. I have set myself a mini project to learn some new php and to have some fun! I was hoping that someone would be kind enough to tell me how difficult this would be to achieve, and how they would best suggest to approach it. I want to create a 'availability checker'. I want to create a field where I can input a date. If the date exists in my mysql database then it returns NO, if the date isn't in the database it returns YES. For a admin area I want to have a place to add dates, and maybe some details about these dates. I don't think its overly complicated, but it should still be quite a challenge for me. Any guidance would be greatly appreciated. Thanks Hi, I'm developing an iPhone app that's going to need data from a MySQL database, it's just a simple list of my bands upcoming gigs. So I understand that I need to build an API - I've found some scripts here and there, I just need some advice as to 'what' I should build...JSON? XML? something else? I don't know anything about it and cant really find anything that will tell me. Hopefully, If I can get a good method going I will be able to use it for various other app ideas. Any suggestions are greatly appreciated. I have been having a coding problem. Went back to the books and came across this bit of information. Can anyone tell me if I should be updating my C drive Enabling file uploads and sessions. the windows installer designates two folders in your user area as the values for upload_tmp_dir and session.save_path. However, file uploads and sessions won't work unles you create the folders yourself. In Windows XP go to C:\Documents and Settings\<username>\Local Settings\Temp. Create a new folder called php, and inside that folder, create two subfolders called upload and session. Is this information true as it is not set in my computer. Just need to know if this will help my session From where I will get Good Notes ?? which site to refer for cake PHP?
Hi Guys, I have an events calender which if theres an events it echos a color if blue on the day. I would like to display the start and end dates on the calender in the same way. Example if and events starts 01/01/2012 and ends 03/01/2012. I'm having problems echoing a blue color from 01/01/2012 to 03/01/2012 to indicate the start and end date of the event. The code belows show how I tried to solve the problem, it works but it thinks the event start from the 1st and end on the 3rd of every month which is wrong. Please show me how I can improve this code or do different to make it work. Thanks Code: [Select] $todaysDate = date("d/m/Y"); $dateToCompare = $daystring . '/' . $monthstring . '/' . $year; echo "<td align='center' "; if($todaysDate == $dateToCompare){ echo "style='class:red'"; }else{ $sqlcount = mysql_query("select * from event where '".$dateToCompare."' >=start_date and '".$dateToCompare."' <=end_date"); $customerCount = mysql_num_rows($sqlcount); // count the output amount while($row = mysql_fetch_assoc($sqlcount)) { $start_date = $row['start_date']; $end_day = $row['end_day']; if($customerCount >= 1){ echo "style='class:blue'"; } } } Hello all, I have tried to fix this many a time before but never managed it. However now it is really annoying me as it clogs up my error file. <?phpsession_start();session_register('sid');if (isset($_SESSION['sid'])) {} else { $tmp = md5(microtime()); $_SESSION['sid']=$tmp; } $db_server = "server";$db_name = "name";$db_user = "user";$db_passwort = "pw";$db = @MYSQL_CONNECT($db_server,$db_user,$db_passwort) or die ("no connection please contact me");$db_check = @MYSQL_SELECT_DB($db_name);?>() This little file is called from every page on my website and is causing this line to appear lots Quote [11/Mar/2012:21:00:18 +0100] PHP Notice: A session had already been started - ignoring session_start() in /home/www/EN/config/config.php on line 2 What is the correct way of setting the session i.e. how do I correctly start it at a given point and then keep it throughout? From my understandin in the older php versions I could have just used session_register('sid'); and didn't need the start (but if I did that then had error) while now I have just read that the session_register('sid') has been removed as of 5.4.0. Help would be muchly appreciated, I don't use php that often, just made my site work in the beginning and ignored this but it annoyed me the other day when I saw the size of the error file. thank you Waliser Right now I have a link list a-z and 0-9. you click one of those links and your taken to page listing all items that start with that character. currently I'm using: Code: [Select] SELECT * FROM my_table where LEFT(`my_item`,1)='$show' ORDER BY my_title ASCall I do right now is just add a link like ?show=a and everything that starts with a is listed. Now here is my problem. I want to listen all items that start with a numeric value listed all on one page instead of being spread across 0-9. If another solution becomes available I'd be more then happy to hear you out. But does anyone know how I can change my query to only list items that start with numbers? Hello there, I am working on a pagination script and have hit a bit of a wall. Here is the script: Code: [Select] <?php include("header.php"); ?> <?php $host = "localhost"; // $user = ""; //username to connect to database $pass = ""; //password to connect to database $db = ""; //the name of the database mysql_connect($host,$user,$pass) or die("ERROR:".mysql_error()); mysql_select_db($db) or die("ERROR DB:".mysql_error()); $max = 25; //amount of articles per page. $p = $_GET['p']; if(empty($p)) { $p = 1; } $limits = ($p - 1) * $max; //view the article! if(isset($_GET['act']) && $_GET['act'] == "view") { $id = $_GET['id']; $sql = mysql_query("SELECT * FROM 3dpics WHERE id = '$id'"); while($r = mysql_fetch_array($sql)) { $title = $r['title']; $url = $r['url']; echo "<div align='center'><img src='$url' width='500' height='500'><br />$title<br /><br /><a href='test.php'>Back</a></div>"; } }else{ //view all the articles in rows $sql = mysql_query("SELECT * FROM 3dpics LIMIT ".$limits.",$max") or die(mysql_error()); //the total rows in the table $totalres = mysql_result(mysql_query("SELECT COUNT(id) AS tot FROM 3dpics"),0); $totalpages = ceil($totalres / $max); echo "<table name='myTable' cellpadding='5' cellspacing='5'>"; echo "<tr>"; //the table while($r = mysql_fetch_array($sql)) { $id = $r['id']; $title = $r['title']; $url = $r['url']; echo "<div id='piccontentalign' align='center'>"; echo "<td><img src='$url' width='225' height='225'><br /><div align='center'><a href='test.php?act=view&id=$id'>$title</a></div></td>"; } echo "</tr></table></div>"; //close up the table for($i = 1; $i <= $totalpages; $i++){ //this is the pagination link echo "<a href='test.php?p=$i'>$i</a>|"; } } ?> All this does is pull the url's of the images out of the database. But, it all shows up on 1 line across the screen! I tried echoing the rows instead, but then it just shows up as 1 line going horizontal. So i'm trying to figure out a way to get 5 pictures per row. This is the code that displays them on the main page: Code: [Select] echo "<table name='myTable' cellpadding='5' cellspacing='5'>"; echo "<tr>"; //the table while($r = mysql_fetch_array($sql)) { $id = $r['id']; $title = $r['title']; $url = $r['url']; echo "<div id='piccontentalign' align='center'>"; echo "<td><img src='$url' width='225' height='225'><br /><div align='center'><a href='test.php?act=view&id=$id'>$title</a></div></td>"; } echo "</tr></table></div>"; //close up the table Thanks for all your help! i need to start up the herirtrix tools by type bash heritrix.sh in open terminal. how to execute this command without opening the open terminal. i want to make a button in webpage that can execute this function. so that everytime i want to start up heritrix, i just click the run button and no need to open the terminal.. thank you.. Hi, I'm trying to alter the code below. It cuurently finds the start and end date of this week, no matter what day you're on. What I now need is to find the start & end date of next week, again, no matter what day you're on of this week Thanks to aleX_hill for the following code: <?php #THIS WEEK $dayOfWeek = date("w"); #The number of the day of the week. Sun = 0, Sat = 1 $todayDayOfMonth = date("d"); #The day of the month $thisMonth = date("m"); #The number of this month. Jan = 1, Dec = 12 $firstDayOfWeek = $todayDayOfMonth - $dayOfWeek; #The day of the month for the beginning of the week (Sun) if($firstDayOfWeek < 1) #The beginning of the week was in the previous month { $monthBeginWeek = $thisMonth - 1; $firstDayOfWeek = $firstDayOfWeek + date("t",mktime(0,0,0,$monthBeginWeek,1,date("Y"))); } else { $monthBeginWeek = $thisMonth; } $lastDayOfWeek = $todayDayOfMonth + (6 - $dayOfWeek); #Get the day of the month of the end of the week (sat) if($lastDayOfWeek > date("t")) #if the day of the month is larger then the number of days in the month { $monthEndWeek = $thisMonth + 1; $lastDayOfWeek = $lastDayOfWeek - date("t"); #Then take the number of days in the week to get the day number of the next week } else { $monthEndWeek = $thisMonth; } $start_of_week = date("Y-m-d",mktime(0,0,0,$monthBeginWeek,$firstDayOfWeek,date("Y"))); #echo $start_of_week; $end_of_week = date("Y-m-d",mktime(0,0,0,$monthEndWeek,$lastDayOfWeek,date("Y"))); #echo $end_of_week; ?> Any help is much appreciated! TIA Hi all, I have a session problem on my development site. Whenever I go to my login screen at www.mydomain.com/my/path/index.php, i get the following error messages: Quote Warning: session_start() [function.session-start]: open(/tmp/sess_f89c3850adf5a752b13f5c6b9022d8c4, O_RDWR) failed: Permission denied (13) in /home/account/public_html/shop_lite/admin/index.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/account/public_html/shop_lite/admin/index.php:2) in /home/account/public_html/shop_lite/admin/index.php on line 2 However, when I go to mydomain.com/my/path/index.php, the error messages aren't there. I am very confused. We don't have an SSL (which google suggested it could be) or any whitespace between the opening php tag. I have chmoded the /tmp directory to 777 but to no avail. Any ideas? My opening code is below: Code: [Select] <?php session_start(); require_once("includes/db_connector.php"); include("includes/cms_class.php"); include("includes/login_class.php"); loginForwarder(); $issue = checkLoginIssue(); if (isset($_POST["login"])) { loginUser($_POST["email"], $_POST["password"]); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/my_template.dwt.php" codeOutsideHTMLIsLocked="false" --> I have issues with a user being logged in and staying logged in, When logging in I create these $_SESSION variables Array ( [usr_login] => username [usr_fname] => first [usr_lname] => last [usr_email] => email [ses_usrid] => 1 [loggdin] => Yes [loginremember] => ) And after login it looks great till I refresh the page or go anywhere else on the site. All variables above are gone. Consequently, this works with no issues on the prod server, just not on my machine. Code I've been playing with since it started, specifically the setting of the cookie. (this code runs before anything else) // ================================================================= // Sesssion start // ================================================================= session_set_cookie_params( 0, "/; SameSite=Strict", ".killgorack.com", true, true ); session_start(); // ================================================================= // Security stuff // ================================================================= header("strict-transport-security: max-age=31536000"); header('X-Frame-Options: sameorigin'); header("X-XSS-Protection: 1; mode=block"); header('X-Content-Type-Options: nosniff'); header("Content-Security-Policy: default-src BLA BLA BLA "); header("Feature-Policy: vibrate 'none'"); header("Referrer-Policy: no-referrer"); header("Access-Control-Allow-Origin: https://www.MYWEBSITE.com/"); header("Expect-CT: max-age=86400, enforce"); header_remove("X-Powered-By"); // ================================================================= Any ideas? Edited May 19, 2019 by KillGorackOk i have just installed anope irc services on my irc network and they use MySQL databases. Through this, I can use the same info/passwords to link user/website accs. However it stores passwords as md5:someHashHere How would i get a php script to remove the md5: from the start, or would it just be easier checking against md5:$md5(enteredpassword)? Hi everyone (sorry for my bad english),
Hello all. Is it possible to have a link that can start and stop a service on the web server? It is a windows 2003 server. Thanks, Mike I need a way to start a program and store the PID, then manage to stop it at the users request later. Im not sure how i would go about this. It has to work on Windows, Any help? Thanks. |