btherl
Staff Alumni-
Posts
3,893 -
Joined
-
Last visited
Everything posted by btherl
-
This is line 16 of your login script: $user_password = mysqli_real_escape_string($dbc, trim($_POST['password'])); The form did not send "password", that is causing the error. Are you saying that you got an error from login.php when you submitted the register.php form? Is the data getting submitted to the wrong script?
-
Does "without validation" mean it stores the data even when some items are empty?
-
Yes it is possible.
-
Sorry, yes it is mysql_error() not mysql_last_error(). "Undefined variable: parent_first_name" means you are using $parent_first_name before you set it. If you have code which sets $parent_first_name, then that code is either not working correctly or it is not being executed. You can debug this by adding print statements throughout your code so you can check which parts are being executed, and why. There is too much code there for me to look through. Does the code work now?
-
Since you're hosting at home, ask your ISP for the SMTP server settings. The relevant configuration variables are listed here: http://au2.php.net/manual/en/mail.configuration.php , and you'll need to enter the settings your ISP gave you. I'm not sure if it can use SMTP servers with authentication though .. if you need that you may need to use the Pear Mail package. But usually an ISP will allow unauthenticated SMTP from their customer ip addresses.
-
Do you fetch the data before or after updating it?
-
Sessions & Mails... Major problems in one thread.
btherl replied to Bencori's topic in PHP Coding Help
Bencori, the things to look for in the headers are described here: http://en.wikipedia.org/wiki/HTTP_cookie#Implementation The request from your browser should be sending a Cookie: header, and the browser should be responding with a Set-cookie: header on each request. The cookie will have the name PHPSESSID -
Yes you can do it in smarty, though it's not really the right tool for the job. But it's dead simple in php. If you can get this php code to run after all the schedule tags then you're set: $mwins = $smarty->get_template_vars('mwins'); $agg_wins = array(); foreach ($mwins as $m) { $agg_wins[$m['team']] += $m['wins']; } $smarty->assign('agg_wins', $agg_wins); Then your smarty code will look like: {foreach from=$agg_wins item=wincount key=teamname}{$teamname} won {$wincount} games<br>{/foreach} If you're allowed you can put the code in smarty's {php} tags, after the {schedule} tags and before the {foreach} that displays the results. BTW this is bad program design, and I would never recommend using {php} tags normally, but I can't suggest any other way without understanding your program's structure better.
-
Hmm.. so is it like this: The schedule tag appears multiple times on the page, and each time it appears, your code gets called. So your code is called once for each schedule tag? Are you able to execute some more php code after all the schedule tags, but before you need to display the total wins per team?
-
Sessions & Mails... Major problems in one thread.
btherl replied to Bencori's topic in PHP Coding Help
Have you tried other browsers for the session issue? I'm not suggesting you ask everyone to change browser, but it may help to debug the problem if it works in some browsers but not others. You may also want to log the headers your browser is sending. You can do this in Firefox with the LiveHTTPHeaders extension. Then you can see if the session cookie is being sent. As for the mail() issue, have you asked the hosting provider about it? You might be able to resolve it by using an external SMTP service instead of the system mail(). It could be caused by other people on your host spamming, resulting in some sites not accepting email from it. -
This means you are either not using the right SMTP server, or you are not providing the right credentials to it. Ask the administrator of the hosting site (or your ISP if hosting at home) what the right SMTP server is. For the login script, do you get an error message?
-
There's a piece missing from the middle of your first query: "useā¦ parent.parent_first_name" Please change your query code to: $result = mysql_query($query, $mysql_link) or die("Query failed: $query\n" . mysql_last_error()); And post the error message from the query here. BTW it is better to use JOIN instead of the commas to combine tables.
-
Oh.. I realize now that your loop is part of a larger loop, which is why you need to use append. Are you able to show the code which loops through each game?
-
Can you post the code you're using now?
-
Did you change this code inside the loop as well: if($home == $winner) { $wins[$winner] += 1; } That's different from the code you posted. Edit: And did you put the loop that prints the results outside the for loop?
-
What happens when you try that?
-
You may need to tell Curl you are doing a post, by setting CURLOPT_POST to 1.
-
Try this: $wins = array(); for ($i=0; $i < count($params['date']); $i++) { $date= $params['date']; $time=$params['time']; $location= $params['location']; $home= $params['home']; $vs= $params['vs']; $winner= $params['winner']; $results= $params['results']; $gameinfo = array("date", "time","location","home","vs","winner","results"); $game_info = compact($gameinfo); if($home == $winner) { $wins[$winner] += 1; } } foreach ($wins as $team => $win_count) { print "$team won $win_count games\n"; }
-
Page won't redirect to HTTPS once SSL is actually applied to the site
btherl replied to dsince1984's topic in PHP Coding Help
Your server guy should be fixing this. Do you get the same error when the script doesn't do any redirects at all? -
Yes you can, as long as your web server is configured to allow sym links for that directory. If you're using apache it's the FollowSymLinks option. You can create them with the php function symlink()
-
What did you try with header?
-
Are you sure it's your regexp removing the html? Try printing your data out using htmlentities() immediately before and after the regexp is applied. Or copy the regexp into a seperate file and use that file for testing it.
-
PHP with HTML = Bad....How do I stop this habit?
btherl replied to 3raser's topic in PHP Coding Help
I'm a professional php developer too and I consider Smarty to be as useful as OOP. It enforces seperation of your data manipulation code and your display code. Just as one of OOP's major benefits is actually that it restricts what you can do, Smarty also restricts you, forcing you to follow good coding practices. OOP => isolation of objects => unit testing, interface preserving changes do not introduce bugs because of isolation => good code Smarty => isolation of logic and display => simple logic code, simple display code, interface code can be changed in isolation of display code and vice versa => good code All of these come down to one principle - break the program down into simple (and isolated) pieces, and make sure each piece works, and that they are combined in a way that works. Then your whole program will work. -
The short answer is it doesn't matter, but it's helpful to choose your delimiter so it doesn't conflict with the regexp. In your case you are looking for a file, so I used pipe instead of slash, as there's a chance $file will have slashes in it. It's very unlikely for it to have a pipe though. You can still use the delimiter but you'll need to escape it. The following are equivalent: '/foo\/bar.txt/' '|foo/bar.txt|' So by choosing pipe as delimiter, there's no need to escape the slash.