-
Posts
1,903 -
Joined
-
Last visited
-
Days Won
3
Everything posted by mrMarcus
-
Array with Keys and Values from mysql results
mrMarcus replied to bschultz's topic in PHP Coding Help
You have defined keys. You are overwriting them with each iteration of the loop. The reason your second code returns expected results is because the keys are incremental (e.g. 1, 2, 3...), and are not being redefined. -
EnregistrementUSer() returns 1 or 0?
-
Search Code - Giving Column Name Keywords?
mrMarcus replied to justlukeyou's topic in PHP Coding Help
Why would you do that? -
Going to be brutally honest... you have a long ways to go You shouldn't compound your query functions like that. Or any function for that matter, unless you have a very good reason to. What I'm referring to is: $row = mysql_fetch_assoc(mysql_query("SELECT id,username,salt FROM tz_members WHERE username='{$_POST['username']}' AND pass='".md5($salt.md5($_POST['password']).$salt)."'")); Swap out this block: $row = mysql_fetch_assoc(mysql_query("SELECT id,username,salt FROM tz_members WHERE username='{$_POST['username']}' AND pass='".md5($salt.md5($_POST['password']).$salt)."'")); if($row['username']) { // If everything is OK login $_SESSION['usr']=$row['username']; $_SESSION['id'] = $row['id']; $_SESSION['rememberMe'] = $_POST['rememberMe']; // Store some data in the session setcookie('tzRemember',$_POST['rememberMe']); } else $err[]='Wrong username and/or password!'; for this block: $sql = "SELECT id,username,salt FROM tz_members WHERE username='{$_POST['username']}' AND pass='".md5($salt.md5($_POST['password']).$salt)."'"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result) > 0) { $row = mysql_fetch_assoc($result); if ($row['username']) { // If everything is OK login $_SESSION['usr']=$row['username']; $_SESSION['id'] = $row['id']; $_SESSION['rememberMe'] = $_POST['rememberMe']; // Store some data in the session setcookie('tzRemember',$_POST['rememberMe']); } else $err[]='Wrong username and/or password!'; } else { $err[] = 'No record found.'; } } else { die(mysql_error()); }
-
Search Code - Giving Column Name Keywords?
mrMarcus replied to justlukeyou's topic in PHP Coding Help
What does echo $query_string; return? -
You really need to start logging your conditions. What I mean is, if any of your ELSE statements are hit, you'll never know. For all you know right now, those 70% of users who think an email is being dispatched are actually waiting for nothing since your code messed up somewhere. So, for each of your ELSE statements, add the following error_log() code and add relevant messages so you know where in the code things are messing up. For example: if ($OkEnregist==1) { //EnvoiEmailConfirmation($username, $MotPasse, $email); RecupInfos($username, $MotPasse); $_SESSION["MessageInscrip_OK"] = "Inscription terminé. Vous pouvez maintenant vous <a href=\"main.php?section=a1SeConnecter\">connecter!</a>"; unset($_SESSION['MessageUSerName']); unset($_SESSION['MessagePassword']); unset($_SESSION['MessageEmail']); //unset($_SESSION['MessageInscrip_OK']); unset($_SESSION['txtUsername']); unset($_SESSION['txtPassword']); unset($_SESSION['txtEmail']); unset($_SESSION['Condition_Majeur']); unset($_SESSION['checkedMajeur']); unset($_SESSION['checkedCondition']); //header("Location: Inscription2.php"); SendEmail($_POST["txtEmail"]); header("Location: Confirmation-Courriel.php"); } else { error_log('$OkEnregist is 0; File: '. __FILE__ .'; Line: '. __LINE__ ."\n", 3, 'email_send_errors.log'); $_SESSION["MessageInscrip_OK"] = "<div class=\"divMsgError\"><table width=\"100%\" height=\"100%\" border=0 cellspacing=0><tr><td align=\"center\" valign=\"center\"><img src=\"Images/Cadres/X.png\"></td><td align=\"left\" valign=\"center\" style=\"padding-left:10px;\" class=\"MsgErrorText\">L'inscription ne s'est pas éffectuer. Une erreur s'est produite</td></tr></table></div>"; header("Location: Inscription.php"); } This way, you can check that log file anytime somebody complains about not getting their confirmation email.
-
How does this happen exactly? lol Change: $salt = $rows('salt'); to $salt = $rows['salt']; and try again.
-
Not to say that PHPMailer is difficult, but if you're having trouble getting emails to send using mail(), you'd better just stick to that for now. Please post the block of code that calls the SendEmail() function.
-
Not necessary. I don't see any code in what you have posted that tells me you're using PHPMailer. Are you trying to use PHPMailer?
-
Can you post the block of code that validates and then calls the SendEmail() function please. You say ~70% of your users are not receiving this email, so that function might not even be getting hit. Also, mysql_numrows() is deprecated. Consider changing to mysql_num_rows(). Not important at this time, but note it.
-
Replace your mail() function with this: if (!mail($Email, $Title, $Sujet , $headers)) { error_log("Email wasn't sent to: $Email\n", 3, 'email_send_errors.log'); }
-
I see the concatenation now. No CODE tags make it difficult to pick up the small things. Please wrap your code in the tags from now on (without the spaces). Don't worry about the translation, please. All that's doing is throwing people off 'cause the variable names don't line up now as I no longer see where $Title, $body, $headers are being defined in your code. Also, I don't see where you are calling your SendEmail() function. Edit: I see you put $title and $headers back in there. For clarity, please just post your code exactly as it is in your script (removing any personal information, of course; but variable names and such need to remain the same).
-
I don't see where you're defining $vEmail in your code. Please post all relevant code.
-
The higher the cardinality, the better. You can see - and use this for future reference - that device has a very low cardinality compared to thetimestamp. People often make the mistake of placing an index on every column thinking that will speed up your system queries, but it can also have a negative impact especially if the optimizer chooses to use that index. When you have a low cardinality, that typically means that you could better normalize your database. As I asked earlier, having ~65K records of the same device in your table seems quite off.
-
PHP & MySQL - Webpage for each "id" from a table
mrMarcus replied to jege's topic in PHP Coding Help
You logic is redundant. You will simply grab the 'id' from the URL and check it against a table in the database. if (isset($_GET['id']) && !empty($_GET['id'])) { $id = $_GET['id']; // from example URL: http://www.example.com/profile.php?id=xxx $sql = "SELECT * FROM `table` WHERE `id` = ". mysql_real_escape_string($id) ." LIMIT 1"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result) == 1) { $res = mysql_fetch_assoc($result); // do stuff here } else { echo 'Record not found.'; } } else { trigger_error(mysql_error()); // remove in production } } -
Do you literally have $Email=user email; in your code? Or did you just put that there for some reason? Is this the exact code you have in place? Your $body variables are overwriting eachother in every instance. You need to change to: $body .= For each after the declaration.
-
It could be a million things. Maybe it's sitting right there in their Spam/Junk mail box. Without code, this is just a big guessing game. Please post relevant code.
-
I would suggest putting an INDEX on (`id`, `device`). I'm assuming you do not currently have an INDEX on `device`? And perhaps you could better normalize your database. You say that this one device, alone, has ~65K results in a single table? Why is that? What's different about each record for that particular device? What is the `latestlocation` index/key made up of? When you hit a CONST as the 'ref', you can *typically* expect fast execution and results. Your initial query was not able to make that same connection. Could you please run: SHOW INDEXES FROM `newlocations`; Within either phpMyAdmin or from shell, and display the results here.
-
Yeah, Go Leafs... :'(
-
Do you have the option to revert from using that column type? You don't want to store images within the database, but instead, simply store the name of the file in the table and have the file located in a folder/directory somewhere on the server. That way, you won't even need to reference a separate show.php file to display the images, either. You will be able to have them display right within teste.php
-
Oh, and don't forget to sanitize incoming (form) data before placing within a query. Look at mysql_real_escape_string. Also, if you are allowing files to be uploaded by the public, you will want to check the MIME types upon upload and not allow for executables or system files (file.exe; file.ini, etc).
-
Where you had: //print_r($_FILES); You can use <pre> tags to help clarify the data: echo '<pre>'; print_r($_FILES); echo '</pre>'; Then you can see exactly what's contained within the array, nice and neat.
-
It's quite simple, actually. And you had the concept within your foreach() loop by using the $key to differentiate between files: if (isset($_POST['submit'])) { if (isset($_FILES['picture'])) { foreach($_FILES['picture']['tmp_name'] as $key => $tmp_name){ move_uploaded_file($tmp_name, "data/{$_FILES['picture']['name'][$key]}"); } $pre_banner = $_FILES['picture']['name'][0]; $pre_logo1 = $_FILES['picture']['name'][1]; $pre_logo2 = $_FILES['picture']['name'][2]; $pre_logo3 = $_FILES['picture']['name'][3]; $querystring = "INSERT INTO presentation_tbl(pre_name,pre_banner,pre_text,pre_link,pre_logo1,pre_logo2,pre_logo3) VALUES(".$preName."','".$pre_banner."','".$preText."','".$preLink."','".$pre_logo1."','".$pre_logo2."','".$pre_logo3."')"; $doquery = mysql_query($querystring); echo "Upload was a sucess"; } else { echo "there was a problem uploading, please try again!"; } }
-
Well, it would make sense to have the query execute only if a file has been uploaded, correct? Having the INSERT query run without a file being uploaded wouldn't make any sense. You need to post the form code as well, please.
-
Specific names of what array? The $_FILES array? Please be more specific as to what values you're looking to derive if that's the case. Also, and perhaps it's just because this is a work in progress, but that final ELSE statement will return an error: } else{ echo "There was an error uploading the file, please try again!"; } as there is no opening IF for it. Maybe you meant to place query within the: if(isset($_FILES['picture'])){ block? Then it should look like this: <?php set_time_limit(0); require_once("Connections/myConnect.php"); mysql_select_db("phpmy1_norfolkartscentre_ca"); $preName = $_POST['name']; $preText = $_POST['text']; $preLink = $_POST['links']; if(isset($_FILES['picture'])){ foreach($_FILES['picture']['tmp_name'] as $key => $tmp_name){ move_uploaded_file($tmp_name, "data/{$_FILES['picture']['name'][$key]}"); } //print_r($_FILES); $querystring = "INSERT INTO presentation_tbl(pre_id,pre_name,pre_banner,pre_text,pre_link,pre_logo1,pre_logo2,pre_logo3) VALUES(NULL,'".$preName."','".$[0]."','".$preText."','".$preLink."','".$[1]."','".$[2]."','".$[3]."')"; $doquery = mysql_query($querystring); echo ""; } else { echo "There was an error uploading the file, please try again!"; }