PHP - Snippet Repository And Tutorials Sections Crusty
The snippet repository section has been read only and nothing new for a long time.
Most of the ones there are pretty old.
The tutorials sections last post was from 2010
The old pagination tutorial needs a good mysqli and pdo version there.
http://www.phpfreaks...asic-pagination
I noticed how slow the sites been a while now, maybe need something to lure more in.
Similar TutorialsHi, The code for displaying a results set in multiple columns (http://www.phpfreaks.com/forums/index.php?topic=95426.0) works really well and displays 1 2 3 4 5 6 7 8 Does anyone know how to change so it displays as 1 3 5 7 2 4 6 8 Any help would be greatly appreciated thanks a Sorry if this is too obvious or hard to understand. I'm echoing a database value onto a webpage, the value in question is a large paragraph of text. I need it to only display the first 40 characters or so of that text, then trail off with a "..." So the users will be able to click a 'More Info' button which will take them to a page containing the full paragraph of text. I'm just not sure how to cut off the text after 40 characters. Any help HUGELY appreciated I really swear that the host I use is like screwing with me hard. Like literally will have something working one night, wake up the next day to my error log full and nothing working anymore. Or, like in this case, have the code working fine, perfectly in fact, to all of the sudden bring up all these errors and shit without changing anything I just can't figure it out. Point being, I am working on this portal, and on the account page, you can update your info. Which for one field... $result = queryMysql("SELECT * FROM accounts WHERE user='$user'"); $row = $result->fetch_assoc(); $set_comp = $row['company']; // Check if 'Company' value is set if (isset($_POST['company'])) { $company = sanitizeString($_POST['company']); if ($_POST['company'] != $set_comp) { queryMysql("UPDATE accounts SET company='$company' WHERE user='$user'"); } elseif ($set_company == "") { queryMysql("INSERT INTO accounts (company) VALUES('$company') WHERE user='$user'"); } elseif (empty($_POST['company'])) { $company = ""; } else { $company = stripslashes($row['company']); } } And the form... Quote<form method='post' action='account.php' enctype='multipart/form-data'> Company:</th><td><input type='company' size='50' maxlength='40' name='company' value='$company'> <input type='submit' value='Save Info'> </form>
Now before it inexplicably stopped working, what it was doing and meant to do was display a form, that either had the information that was set, or displayed nothing because nothing was entered, and you could either put something there or change what was already there. Now it keeps telling me: [22-Oct-2018 06:29:37 UTC] PHP Notice: Undefined variable: company in /home/iqy0804tq6fq/public_html/portal/account.php on line 262 Also, sanitizeString and queryMysql are my own created functions, they work fine. I tried removing the elseif (empty($_POST['company'])), and just left the last else in, didn't work. It just displays empty columns now. Now also, when I try to update, it feeds me all these errors now my SQL syntax is wrong its LIKE HOW DID THIS CHANGE IN 10 SECONDS!!? I didn't DO anything for my syntax to be any different than when it worked perfectly! It's insanity. I have this snippet that pulls up a confirmation page and requires a click to confirm before deleting the input member (or gives invalid member error), I have been completely unsuccessful removing the confirmation step and just deleting the member with success...
case 'deletemember': if (!isset($_POST['deletemember']) && !isset($confirm)) { $delmembername = null; print eval(get_template('delete_member')); } else { if (isset($confirm) && isset($mid)) { mysql_query("DELETE FROM members WHERE member_id='$mid'") or die(mysql_error()); mysql_query("UPDATE topics SET topic_rid=0 WHERE topic_rid='$mid'")or die(mysql_error()); mysql_query("UPDATE topics SET topic_lrid=0 WHERE topic_lrid='$mid'")or die(mysql_error()); mysql_query("UPDATE replies SET reply_aid=0 WHERE reply_aid='$mid'")or die(mysql_error()); show_message('Member deleted'); } else { $result = mysql_query("SELECT member_id FROM members WHERE member_name='$delmembername'"); if (mysql_num_rows($result) == 0) show_message('Member invalid'); else { $mid = mysql_result($result, 0); $board_title = sprintf('Delete '.$delmembername.'?'); $message = $board_title; $confirmed_link = '<a href="admin.php?a=deletemember&mid='.$mid.'&confirm=1">Delete</a>'; print eval(get_template('confirm')); } } } break;Can anyone help me here, I know it has to be something simple, I'm just not that great at PHP. Hi hi, CAn anyone tell me why this piece of code doesn't work? Code: [Select] <?php function readDirs($main){ $dirHandle = opendir($main); while($file = readdir($dirHandle)){ if(is_dir($file) && $file != '.' && $file != '..'){ readDirs($file); } else{ echo $file . '<br/>'; } } } $dir = '../../lib'; readDirs($dir); ?> It must show all the files in the directory, but only shows: Code: [Select] . .. technical This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=307368.0 I am looking to learn CakePHP are there recommendations for tutorials on CakePHP?
This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=316250.0 Hello Guys, can anyone know any tutorials or script to make a reminder program that will remind the user in advance. Your concern and help is highly appreciated. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=320875.0 I have an array, and to make it easy let's say they have 2 values: ET and SPEED Here is an example chart of the array printed out: KEY ET SPEED 8 5.2 60 3 5.3 60 1 5.4 70 7 5.4 60 9 5.4 90 6 5.5 60 5 5.6 60 2 5.6 65 4 5.7 60 I need to take this array and each group that has a matching ET, put them in order based on SPEED. The corrected chart should be like this: KEY ET SPEED 8 5.2 60 3 5.3 60 9 5.4 90 1 5.4 70 7 5.4 60 6 5.5 60 2 5.6 65 5 5.6 60 4 5.7 60 Just not sure of how to only arrange the section that need to be. Keys stay the same, just the order changes. so i have this string that i want to search on the database My database has 3 parts city, state, country and i have a string that is say "new york city, ny, united states" and i want to be able to be able to look into the database but search those three sections so for example "New York City" i would like to search under city "NY" i want it to search under state and "United States" i want to search under country so basically how can i split the string into those three sections?? hope someone can help me with this This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=333807.0 I tried to find working tutorial for REST API and with these two frameworks but nothing what i found worked.Basicly i want to attach REST API
to a simple CRUD application.
So if anyone have links with good explanation that would be good.
This should be an easy one but I'm looking for a bit of help. I'm using a php framework and using includes to bring different pieces of a website togethor onto the page. The top of the page uses a flash banner, then there are some simple text sections below. The banner is in it's own php file as well. Wondering if it's possible to have the banner NOT replay after each page load? I'm not sure if this is something I need to setup in the flash file, or if there is a way to do it in the php files? Basically, the banner is the same for all of the pages, and I want it (once loaded) to stay on the page while the details on the bottom change, WITHOUT going through the entire animation again. Make sense? here's the page as it stands now so you can get a better idea what I'm trying to do. http://www.getmoreimpact.com/index.php again not sure if this needs to be done in the flash side, or the php? Any ideas are better than what I've got! Thanks in advance I need help arranging a text blob into a table of where each cell is a letter, and the contents of the text blob must be arranged in the table according to what letter it starts with. This is the query I used: $gibs33 = mysql_query("SELECT name,anime_id,sort FROM anime WHERE popular='1' ORDER BY name ASC"); while ($gib33 = mysql_fetch_assoc($gibs33)) { echo '<a href="http://www.website.com/index.php?anime_id='.$gib33['anime_id'].'">'.$gib33['name'].'</a> | '; } The text blob looks like this: Quote <a href="http://www.narutosoul.com/index.php?categoryid=2&task=series&anime_id=132">Appleseed (2004)</a> | <a href="http://www.narutosoul.com/index.php?categoryid=2&task=series&anime_id=133">Appleseed: Ex Machina</a> | <a href="http://www.narutosoul.com/index.php?categoryid=2&task=series&anime_id=219">Black Rock Shooter</a> | <a href="http://www.narutosoul.com/index.php?categoryid=2&task=series&anime_id=2">Bleach</a> | <a href="http://www.narutosoul.com/index.php?categoryid=2&task=series&anime_id=191">Bleach: Diamond Dust Rebellion</a> | <a href="http://www.narutosoul.com/index.php?categoryid=2&task=series&anime_id=192">Bleach: Fade to Black</a> | <a href="http://www.narutosoul.com/index.php?categoryid=2&task=series&anime_id=190">Bleach: Memories of Nobody</a> | <a href="http://www.narutosoul.com/index.php?categoryid=2&task=series&anime_id=175">Brave Story</a> | <a href="http://www.narutosoul.com/index.php?categoryid=2&task=series&anime_id=207">Canaan</a> | <a href="http://www.narutosoul.com/index.php?categoryid=2&task=series&anime_id=24">Clannad</a> | <a href="http://www.narutosoul.com/index.php?categoryid=2&task=series&anime_id=26">Code Geass Lelouch of the Rebellion</a> | <a href="http://www.narutosoul.com/index.php?categoryid=2&task=series&anime_id=206">Code Geass Lelouch of the Rebellion R2</a> | I want to arrange this blob into a table like this: #-9 A B C D E .Hack AppleSeed Bleach Blood+ Basilisk Claymore D Gray Man Eureka 7 Elfen Lied F G H I J K Fairy Tail Gundam Seed K-ON Season 2 etc.... In the Query, anime_id = number example: (189) sort = First letter of the word, example (N) name = Name of the anime, example (Bleach) This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=342385.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=343257.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=334128.0 I'm trying to organize MySQL output in an HTML table based on individual states. Here is how the static HTML is currently displayed: http://www.u-s-s-a.org/breeders.html. Here is my working document: http://www.u-s-s-a.org/breeders.php. As you can see on the HTML page, each db row is organized into individual states. I'm only concerned about the US states, and not the countries outside of the US. Following is the code I've been working on (directoryoutput.php): Code: [Select] <?php require '/home/srob/public_html/u-s-s-a.org/config.php'; $connect = mysql_connect ($dbhost, $dbuser, $dbpass) or die ('Cannot connect: '.mysql_error()); mysql_select_db ($dbname); $query = "SELECT * FROM directory ORDER BY flockname"; $result = mysql_query($query) or die ('Error, query failed.'); echo "<tr><td width='33%' class='style9'><p align='left' class='style12'><a name='AR'></a>Arkansas</p></td><td width='34%'> </td><td width='33%' valign='top'><div align='right'><a href='#TOP'><img src='returnTOTOPGRAPHIC/RETURNTOTOP.gif' width='113' height='21' border='0' align='absmiddle'></a></div></td></tr>"; $cnt = 0; while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ if ($cnt == 0){ echo "<tr><td valign='top' class='style9'><p align='center'><span class='style10'><strong>"; if($row['flockname']){ echo $row['flockname']; } echo "</strong></span><strong></br>"; if($row['firstname']){ echo $row['firstname']." ".$row['lastname']."</br>"; } if($row['address1']){ echo $row['address1']."</br>"; } if($row['address2']){ echo $row['address2']."</br>"; } if($row['city']){ echo $row['city'].", ".$row['state']." ".$row['zip']."</br>"; } if($row['email1']){ echo "<a href='mailto:".$row['email1']."'>".$row['email1']."</a></br>"; } if($row['email2']){ echo "<a href='mailto:".$row['email2']."'>".$row['email2']."</a></br>"; } if($row['website1']){ echo "<a target='_blank' href='http://".$row['website1']."'>".$row['website1']."</a></br>"; } if($row['website2']){ echo "<a target='_blank' href='http://".$row['website2']."'>".$row['website2']."</a></br>"; } echo "</br></p></td>"; $cnt++; } elseif ($cnt == 1){ echo "<td valign='top' class='style9'><p align='center'><span class='style10'><strong>"; if($row['flockname']){ echo $row['flockname']; } echo "</strong></span><strong></br>"; if($row['firstname']){ echo $row['firstname']." ".$row['lastname']."</br>"; } if($row['address1']){ echo $row['address1']."</br>"; } if($row['address2']){ echo $row['address2']."</br>"; } if($row['city']){ echo $row['city'].", ".$row['state']." ".$row['zip']."</br>"; } if($row['email1']){ echo "<a href='mailto:".$row['email1']."'>".$row['email1']."</a></br>"; } if($row['email2']){ echo "<a href='mailto:".$row['email2']."'>".$row['email2']."</a></br>"; } if($row['website1']){ echo "<a target='_blank' href='http://".$row['website1']."'>".$row['website1']."</a></br>"; } if($row['website2']){ echo "<a target='_blank' href='http://".$row['website2']."'>".$row['website2']."</a></br>"; } echo "</br></p></td>"; $cnt++; } elseif ($cnt == 2){ echo "<td valign='top' class='style9'><p align='center'><span class='style10'><strong>"; if($row['flockname']){ echo $row['flockname']; } echo "</strong></span><strong></br>"; if($row['firstname']){ echo $row['firstname']." ".$row['lastname']."</br>"; } if($row['address1']){ echo $row['address1']."</br>"; } if($row['address2']){ echo $row['address2']."</br>"; } if($row['city']){ echo $row['city'].", ".$row['state']." ".$row['zip']."</br>"; } if($row['email1']){ echo "<a href='mailto:".$row['email1']."'>".$row['email1']."</a></br>"; } if($row['email2']){ echo "<a href='mailto:".$row['email2']."'>".$row['email2']."</a></br>"; } if($row['website1']){ echo "<a target='_blank' href='http://".$row['website1']."'>".$row['website1']."</a></br>"; } if($row['website2']){ echo "<a target='_blank' href='http://".$row['website2']."'>".$row['website2']."</a></br>"; } echo "</br></p></td></tr>"; $cnt = $cnt - 2; } } mysql_close($connect); ?> I'd appreciate any help on this code, including a more efficient way to parse out the MySQL db rows into 3 columns in the HTML table. Thanks in advance! Ryan |