ignace
Moderators-
Posts
6,457 -
Joined
-
Last visited
-
Days Won
26
Everything posted by ignace
-
need to create a link which deletes a record based on login info.
ignace replied to webguync's topic in PHP Coding Help
No otherwise you would have gotten the same error in that previous script. Otherwise remove all those lines ($temp = .. to $value = $temp : and just keep $value = addslashes($value); and see if the error then still turns up. -
Possibly because you are running XAMPP on the background?
-
need to create a link which deletes a record based on login info.
ignace replied to webguync's topic in PHP Coding Help
Same here so what line did you get that error? and what is on that line and the line above and below? -
Well sure but I'm gonna need some more info because your code does not make a lot of sense like what are the "else" for? When I rewrite it I get: $course_title = trim($course_title); $course_maxweeks = 48; if ('Business English' === $course_title) { $course_maxweeks = 2;//?? } else if ('IELTS Exam Preparation' === $course_title) { for ($week = 4; $week <= $course_maxweeks; $week += 4) { echo '<option>', $week, '</option>'; } } else if ('IELTS Foundation Test Course' === $course_title) { for ($week = 4; $week <= $course_maxweeks; $week += 4) { echo '<option>', $week, '</option>'; } } else { for ($week = 2; $week <= $course_maxweeks; ++$week) { echo '<option>', $week, '</option>'; } } Notice the question marks on top
-
Check if a user is following another user (social networking site)
ignace replied to adambedford's topic in PHP Coding Help
SELECT (CASE WHEN f.follower IS NULL THEN 'Yes' ELSE 'No' END) AS following, b.* FROM businesses b LEFT JOIN followers f ON b.id = f.followee What this code does is it selects all records from the table businesses and then left joins it with relationships. So let's assume we have 3 businesses and one user is following 2 of them: businesses 1, business_name1, telephone1, .. 2, business_name2, telephone2, .. 3, business_name3, telephone3, .. relationships 1, 1 1, 2 If I know perform a left join I get as a result: business_id, business_name, business_telephone, .., relationships_follower, relationships_followee 1, business_name1, telephone1, .., 1, 1 2, business_name2, telephone2, .., 1, 2 3, business_name3, telpehone3, .., NULL, NULL Notice the NULL these indicate businesses the user is not following so we could to this in PHP itself but MySQL has the data... (CASE WHEN r.follower IS NULL THEN 'Yes' ELSE 'No' END) AS following In PHP I can check if the user is following the business with: echo $row['following'];//Yes|No I use follower and followee to make it easier to read then to use id1, id2. You should also notice that a business does not follow a user so the followee column always contains the id of a business never that of a user therefor we don't need hard-to-read stuff like: (id1 = u.id or id1 = b.id) and (id2 = u.id or id2 = b.id) SELECT (CASE WHEN r.follower IS NULL THEN 'Yes' ELSE 'No' END) AS following, b.* FROM businesses b LEFT JOIN relationships r ON b.id = r.followee WHERE r.follower = $uid -
Cant add anything to this page, otherwise it will be blank...
ignace replied to KC8Alen's topic in PHP Coding Help
foreach ($_FILES ++ as $file) Is wrong and should be: foreach ($_FILES['upload'] as $file) But this only works if you uploaded multiple files or you declared name="upload[]" -
function thirdparty_linkification($content) { //.. } plugin_register('news_content', 'thirdparty_linkification'); Assum a third-party developer wrote this. His plugin will linkify e-mails and http links in news articles more specifically in the content (body) of the article. I as a developer then write: function cms_get_latest_news($number = 10) { //.. while ($article = mysql_fetch_assoc($result)) { $article['content'] = plugin_apply('news_content', $article['content']); } return $articles; } This will give each and every registered plugin a chance of doing what it wants to do (linkify, footer, ..) I could expand this by adding for example news_time which will give every plugin a chance of telling how it should be formatted and so on.
-
Plus would your text file be faster you think without it's indexes? Not to mention it's size?
-
Are you referring to "Duration of Accommodation" that goes from 2 to 48? And what code do you use for this?
-
That is not a problem it will take a serious amount of time before you start noticing and even then you still have options like clustering and partitioning.
-
What do you mean with "more challenging"?
-
Need help with PhP Home work.. Due in a few days!!!!
ignace replied to stupid21's topic in PHP Coding Help
If you are amazed over this then you should have seen the things that a teacher wrote in front of class on his beamer in college. And let me tell you that they do not like it when you point out their mistake(s)... Hell I heard they had an internal team working on their website.. and yeah those bugs were present there to. Login was as simple as: ' OR 1=1 -- I even had once a teacher which was a head of a company that created websites for big clients and had their framework open-sourced. So when I took a peak at the code... -
displaying both elements of a randomly picked associative array
ignace replied to AdRock's topic in PHP Coding Help
foreach (array_rand($towns, 120) as $key) { print $towns[$key]; } -
Need help with PhP Home work.. Due in a few days!!!!
ignace replied to stupid21's topic in PHP Coding Help
try this: if (isset($_POST['header'])) { $header = intval($_POST['header']); echo 'You choose: ', $header; // outputs: 1, 2 or 3 //.. } -
Check if a user is following another user (social networking site)
ignace replied to adambedford's topic in PHP Coding Help
I wonder if this could work? SELECT b.*, following AS (CASE (SELECT * FROM followers WHERE (id1 = u.id or id1 = b.id) and (id2 = u.id or id2 = b.id)) WHEN NULL THEN 0 ELSE 1 END) FROM businesses b, user u WHERE u.id = $uid; In your PHP you would then just check: if (0 == $row['following']) { echo '<follow/>'; } Edit: silly me SELECT (CASE WHEN f.follower IS NULL THEN 'Yes' ELSE 'No' END) AS following, b.* FROM businesses b LEFT JOIN followers f ON b.id = f.followee -
need to create a link which deletes a record based on login info.
ignace replied to webguync's topic in PHP Coding Help
Weird do you get that error by using the clean() function? Because I ran this little test: error_reporting(E_ALL); ini_set('display_errors', 1); function clean($value, $db = null) { $value = strip_tags($value); $value = htmlentities($value); $temp = @mysql_real_escape_string($value, $db) ? $value = $temp : $value = addslashes($value); return $value; } $var = 'hello world'; $var = clean($var); And didn't return any errors. -
Yes just remember to add indexes if not primary key.
-
Need help with PhP Home work.. Due in a few days!!!!
ignace replied to stupid21's topic in PHP Coding Help
First rename your checkboxes to radio buttons <input type="radio" .. Then make sure all input's have the same name: <input type="radio" name="header" value="1" .. <input type="radio" name="header" value="2" .. <input type="radio" name="header" value="3" .. Your user is now only able to select 1 header. In your PHP you write: if (isset($_POST['header'])) { $header = intval($_POST['header']); //echo $header; // outputs: 1, 2 or 3 //.. } The rest is up to you -
need to create a link which deletes a record based on login info.
ignace replied to webguync's topic in PHP Coding Help
I think you deleted a little to many post your code -
I also want to give you some friendly advice: buy a book on software development and read the sections about variable types and conversions very carefully. A good start: http://www.php.net/manual/en/language.types.php You should just like me be able to tell that after the instruction: $adebt=($adue-$apaid)== mysql_real_escape_string($_POST['adebt']); $adebt = false; and that in an integer context it translates to 0 unless $adue - $apaid indeed match adebt in which $adebt = true and 1 shows up in your db if you had used === then $adebt would have always been false (yes, you must be able to tell that in a blink of an eye)
-
THIS. This is wrong! $adebt=($adue-$apaid)== mysql_real_escape_string($_POST['adebt']); Which also explains the 0 as false in an integer context shows up as 0 and like Mchl said it's: $adebt=($adue-$apaid); It's that simple get rid of that .._string($_POST['adebt']);
-
youtube.. you are in for some trouble