premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
email attachment showing up but printing wrong size
premiso replied to shizny's topic in PHP Coding Help
My bet is, outlook is the culprit. Especially outlook express, that is the old version and I do not even think it is supported my M$ anymore (I could be wrong). But yea...try to see if you can google, "email images cropped outlook" and see if someone else has had similar issues... Because if the image looks fine in the email and only messes up when it is printed and it works on other email platforms, chances are OE is causing the issue. -
Do you have any code or attempts to show us, or you just looking for us to magically conjour this up from thin air and provide you full code?
-
Put the html after the php code?
-
mysql_fetch_row(): supplied argument is not valid
premiso replied to jboku's topic in PHP Coding Help
Chances are you have an error in your sql query. $query_result=mysql_query($sql_query,$database_connection) or die("Error: " . mysql_error()); Add that in there and see what error gets spit out (if any). -
http://edrackham.com/php/get-days-between-two-dates-using-php/ The above solution was found by googling: php days between
-
You should look into strtotime and date. Alternatively, if you know the format is always the same, you can just use explode to re-construct the string. EDIT: Well I just read the title, if you are pulling it from a MySQL DB, look into MySQL Date and Time Functions as you can pull it out how you want it in the query instead of using up PHP's processing time to do it for you.
-
lol, yea that would do it Hashing the nick over the password. Well at least you got it figured out and learned some new tips along the way
-
I do not think you need to call session_destroy in the way you are doing it. I would only call it on a logout. As far the md5 not being the same, chances are you have Magic_Quotes turned on. If that is the case you will either need to strip the slashes from the password first, or just disable magic quotes in your php.ini file since it is depreciated and this will cause you problems once you upgrade. A quick fix, strip_slashes on the password before hashing it.
-
You need to set the header in your php to be image/jpeg. Look at the PHP Manual page for details/instructions.
-
Ok so what is the issue? I guess I am not clear on what we are trying to solve here... As a shot, from your original statement you said that if you login with a username that has a number in it, it does not log you in properly...correct? So the userid 6 and 4 are the ones causing you problems...correct? Have you tried printing out data on the login form to make sure that correct data is being passed through and not getting garbbled up? If you are using sessions, do you have session_start set somewhere in your script (preferably near the top)? Are you sure you are getting the correct return results from the SQL Query (print that out to test as well)? Check those items and let me know, because as far as I can tell it "should" work unless we are not seeing something that you have left out or there is a new problem that needs to be explained/described...
-
<?php session_start(); foreach($_POST as $key => $val) { if(empty($val)) { $errors .= "$key is empty<br />"; } } // lets make sure we have error data first if (strlen($errors) > 0) { $_SESSION['Form Errors'] = $errors; } Header('Location: ../somewhere.php'); ?> Somewhere.php: <?php session_start(); if (isset($_SESSION['Form Errors'])) { echo "The following errors have been encountered: <br />" . $_SESSION['Form Errors']; }else { echo "Thank you for submitting your data error free!"; } ?> Exit is not needed in how you have been using it, php will exit itself automatically. And also, calling session_destroy after setting a session value is contradictive, as it will destroy the session before you get to use it...so there was no point to set a session variable in the first place. EDIT: Just added an else at the end of somewhere.php
-
<input type=\"text\" name=\"first\" /> You were missing an = after the name on that line. Give that shot and see how it goes.
-
The reason it only echos the first is you have exit; Remove that line and it will show all errors. Exit does at it suggests and exit's the script completely. You may have been looking for continue; instead, which will continue the loop. (Only needed if you do not want to proceed with the current loop item if an error is found.)
-
It sounds like the session/cookie data is carrying over, are you clearing that out before re-logging in? I would add a check to your script, if there is already a user session/cookie data, such as the id in cookies, then do not log them in. Inform them they are already logged in and offer them a logout button.
-
[SOLVED] Echoing pagination whilst inside an echo
premiso replied to Irresistable's topic in PHP Coding Help
Look at the syntax highlighting. Get Notepad++ or another editor that highlights syntax... if the colors are off, your code is screwed up either way. Fix the syntax errors (which are basic) then work on the logistics. Just a note, you do have to close your syntax properly before running another set of php codes, echo's are not a catch all, open it and the code will run. You have to close them when you are done with the statement before you can execute anymore PHP code. I would really go look up the basics of PHP syntax if I were you before I continued coding, as it does seem that you lack that knowledge. (Not to be rude, but it will help knowing the syntax's do's and don'ts). -
Read below for solution to your issue also I put some pointers commented in the code: <?php // Connect to MySQL include ( '../MySQLconnect.php' ); // Shouldnt you do the error reporting before you include any files? error_reporting ( E_ERROR ); @ini_set ( 'display_errors', '1' ); // username and password sent from form $myusername = $_POST[ 'nick' ]; $mypassword = md5 ( $_POST[ 'password' ] ); // To protect MySQL injection // You should really check if magic_quotes are on before you stripslashes. // If they are not on, dont strip slashes. $myusername = stripslashes ( $myusername ); // You do not need to stripslashes on an md5 hash // $mypassword = stripslashes ( $mypassword ); $myusername = mysql_real_escape_string ( $myusername ); // You do not need to escape an md5 hash //$mypassword = mysql_real_escape_string ( $mypassword ); // The below statement is bad, because you are using double quotes to check data. // You should always use single quotes when testing SQL data. //$sql = 'SELECT * FROM `user` WHERE `user_nick` = "' . $myusername . '" AND `user_password` = "' . $mypassword . '" AND `user_onoff` = "1" AND `user_delete` = "0" '; $sql = "SELECT * FROM `user` WHERE `user_nick` = '" . $myusername . "' AND `user_password` = '" . $mypassword . "' AND `user_onoff` = '1' AND `user_delete` = '0'"; $result = mysql_query( $sql ); $count = mysql_num_rows ( $result ); $UsrId = mysql_fetch_array ( $result ); if ( $count == '1' ) { /*session_register is depreciated session_register ( 'myusername' ); session_register ( 'mypassword' ); */ $_SESSION['myusername'] = $myusername; $_SESSION['mypassword'] = $mypassword setcookie ( 'nick', $myusername, NULL ); // It is not a good idea to store passwords in a cookie, keep them in session this is a security vunerability. // instead add a new column to the table call it "sessionid" and store that in a cookie // then you can check the cookies session id to the db and authenticate them with that, but this // needs to be a random hash and regenerated each time the user comes to the site. // setcookie ( 'pass', $mypassword, NULL ); setcookie ( 'user_id', $UsrId[ 'user_id' ], NULL ); header ( 'location:IndexInput.php' ); } else { echo 'BAD login'; } ?> Fix the issues (with the exception of the passworded cookie) it should run smooth. The real problem was you were using double quotes ( " ) to test SQL data, when that is wrong. You need to use single quotes ( ' ) to test SQL data, as that is the proper syntax for it.
-
Yes, please post the script....at least the relevant portion. Without it we cannot help you fix your problem.
-
Grab output from another websites form after input.
premiso replied to FaT3oYCG's topic in PHP Coding Help
Yes, you are going to want to look into curl as it can handle post data etc. -
[SOLVED] Why does $username work for one bit and not another
premiso replied to Irresistable's topic in PHP Coding Help
It does, try this: <?php header('location: member.php?user=$username'); ?> It will print $username. A variable inside double quotes ( " ) is interepted. But inside a single quote ( ' ) it is taken literally, this not interepted/parsed. If that does not make sense, please let me know and I will elaborate. -
[SOLVED] Why does $username work for one bit and not another
premiso replied to Irresistable's topic in PHP Coding Help
echo('<strong>'.ucwords($username).' - <a href="member.php?user=' . $username . '">My Account</a> - <a href="logout.php">Logout</a></strong>'); Because you are in single quotes, $ are taken literally. You have to concatenate the variable into the string for it to show. -
Looking for a more efficient way to write this script
premiso replied to taylor's topic in PHP Coding Help
You are only opening a socket once with the GetRecipient function. The rest just parse the return data, so yea. You are already only opening/closing the connection once in that code, as there is no loop in the data. If I missed something, sorry. Been away for a while, but as far as I know it looks alright and only does 1 connection. -
<?php // A simple for loop that outputs our final data. for($x=0;$x<count($story_array);$x++){ echo "\t<h2>" . $story_array[$x]->headline . "</h2>\n"; echo "\t\t<br />\n"; echo '<a href="' . $story_array[$x]->links . '">'; echo "\t<i>" . $story_array[$x]->description . "</i>\n"; echo "</a>"; echo "\t\t<br />\n"; } ?> You overcomplicated it. Keep it all in echos and it should work just fine for you.
-
Well you are checking if maxpages is greater than 10, if it is you set it to 10...why would it goto 11 given that logic?
-
[SOLVED] any ideas why file() function isn't working?
premiso replied to micah1701's topic in PHP Coding Help
If you are on shared hosting, most of the time they disable the retrieval of files through fopen items, such as file. You can try using curl to retrieve the contents and see if that will work, that is if your host has curl installed.