
DaveyK
Members-
Posts
289 -
Joined
-
Last visited
-
Days Won
1
Everything posted by DaveyK
-
the right way according to who? Less and SASS always you as much nesting as you want, nothing against that.
-
So, what is the problem? Also, this is wrong: $myusername = mysql_real_escape_string ($_POST['myusername']); $mypassword = mysql_real_escape_string ($_POST['mypassword']); $myusername = htmlspecialchars ($_POST['myusername']); $mypassword = htmlspecialchars ($_POST['mypassword']); The second $myusername will overwrite the first $myusername. Try: $myusername = mysql_real_escape_string ( htmlspecialchars ($_POST['myusername'])); $mypassword = mysql_real_escape_string ( htmlspecialchars ($_POST['mypassword']));
-
Thats correct. The error wouldve reported that
-
In the future, if you want to know what the error is, you should be able to do something like: }else{ //if unable to update new record echo "Database Error: Unable to update record.<br>"; echo $mysqli->error; }
-
People helping you solve problems are not even remotely responsible for your design, which is what is being discussed at this point. and "some of your header and footer"... ITS A LOT
-
The system shouldnt me too hard to complete, but no one here is going to build it for you so the real thing we are looking for is some code you already wrote and where you got stuck.
-
How to print all images stored in a file Directory?
DaveyK replied to Jenksuy's topic in PHP Coding Help
Which mean that your glob() function returns false. False is not an array and that is why the foreach fails. Now, why is it returning false? Because of some error! Have you turned on error reporting? -
How to print all images stored in a file Directory?
DaveyK replied to Jenksuy's topic in PHP Coding Help
Use a var_dump on $files, its likely that its not what you expect it to be. <?php $files = glob('wp-content/uploads/1/*'); echo '<pre>' . print_r($files, true) . '</pre>'; var_dump($files); die(); foreach($files as $file) { echo '<img src="/' . $file . '" />'; } ?> -
It all really depends on what you want to do... If there is no user involved (or you want all of it on the backend), you can use file_get_contents() right?
-
You should seperate your pages logic from the HTML, meaning you shouldnt be processing PHP in your HTML, but merely displaying it. Try to move all those IF statements to the top, like so: <?php if () { (...) } ?> <html> </html>
-
Hey Adam, - to be honest I cant be bothered by older version of IE - I still float FAR less then the OP did. In my case, the page will actually increase in size if you add content, which was not the case with the design the OP posted. - Whether using all floats is good or not is some discussion I am not willing to go into. I personally dislike it, you may think its great. Thats not why this thread exists. It wasnt working dynamically in the design the OP posted and I pointed out a solution. Feel free to have criticism on the critique, but at least have a saying on the TOPIC at hand, which is the design the OP posted.
-
You should turn on error reporting.
-
ofc this works, but thats exactly what you DONT want. Please put your code in code blocks. What you need to think about is: how can I solve this issue on my own without making someone else do it for me. You have two error messages, so copy the first and google it. http://bit.ly/11GeVRp The first link is a stackoverflow question. The answer is on that page. Do some research and dont expect us to do it for you.
-
The session on a page will only exist if you call session_start() on that page, and as the var_dump shows the issue you are facing has nothing to do with your update. The issue lies in the fact that you dont have a session active on that page. Make sure you have a session and go from there.
-
That is because you are not creating a session, check out the function session_start() and how you can use it. Also, I PRESUME you are checking for a session because you have some sort of login functionality. Since you built a login system, I presume you also know how to handle sessions.
-
If nothing is echoed then that means your SESSION is not set. Try doing a var_dump on $_SESSION on the top of the page, like so: <?php define('upath','mismatch/images1/'); define('msize',1024*50); var_dump($_SESSION); die(); // kill the rest of the page if(isset($_SESSION['user_id'])) { What does that echo?
-
Are you sure you are looking at the correct file? Its called httpd.conf. Also, even tho that exact string may not be in there, you should be creative enough to search if the current root location is in there and you should know what to do from there.
-
HERE, this is what we need. Not a file, but code in code blocks: <?php define('upath','mismatch/images1/'); define('msize',1024*50); if(isset($_SESSION['user_id'])) { $id1=$_SESSION['user_id']; if(isset($_POST['submit'])) { $dbc=mysqli_connect('localhost','root','','mismatch') or die('Error connceting database'); if((!empty($_POST['fname']))&&(!empty($_POST['lname']))&&(!empty($_POST['bday']))&& (!empty($_POST['sex']))&&(!empty($_POST['nation']))) { $fname=$_POST['fname']; $lname=$_POST['lname']; $bday=$_POST['bday']; $sex=$_POST['sex']; $nation=$_POST['nation']; if(!empty($_FILES['screenshot']['name'])) { $screenshot=$_FILES['screenshot']['name']; if(($_FILES['screenshot']['size']>0)&&($_FILES['screenshot']['size']<msize)) { $target=upath.$screesnhot; if(move_uploaded_file($_FILES['screenshot']['tmp_name'],$target)) { $query="SELECT * FROM mismatch_user WHERE user_id=$id1"; $result=mysqli_query($dbc,$query) or die('Error getting data'); if(mysqli_num_rows($result)==1) { $query1="UPDATE mismatch_user SET firstname='$fname', lastname='$lname', birthday='$bday',". "gender='$sex', country='$nation', picture='$screenshot' WHERE user_id='$id1'"; $result1=mysqli_query($dbc,$query1) or die('Error quering database'); echo'<br/><b>Profile Edited successfully</b>'; } } else { echo'<br/><b/>File cannot be uploaded'; } } else { echo'<br/><b/>Check size of Image.'; } } else { $query2="UPDATE mismatch_user SET firstname='$fname', lastname='$lname', birthday='$bday',". "gender='$sex', country='$nation' WHERE user_id='$id1'"; $result2=mysqli_query($dbc,$query2) or die('Error quering database'); echo'<br/><b>Profile Edited successfully</b>'; } } else { echo'<br/><b/>Please Enter all the information.'; } } } ?> <html> <head><title> Edit Profile </title></head> <body> <h1 style="color:brown;"><center>Please Edit your profile to find new mismatch.</center></h1> <form enctype="multipart/form-data" method="post" action="<?php echo$_SERVER['PHP_SELF']; ?>"> <p><i><center>This information would be seen by others and easily get connected to you.</center></i></p> <hr/> <img src="images1\mismatch.jpg" width="400" height="400" alt="mismatch image." align="right"> <fieldset style="width:250"> <legend>Edit your profile</legend> <table><tr> <td><label for="fname">Firstname:</label></td> <td><input type="text" id="fname" name="fname"><br/></td> </tr><tr> <td><label for="lname">Lastname:</label></td> <td><input type="text" id="lname" name="lname"><br/></td> </tr><tr> <td><label for="bday">Birthday:</label></td> <td><input type="text" id="bday" name="bday"><br/></td> </tr><tr> <td><label for="sex">Gender:</label></td> <td><input type="text" id="sex" name="sex"><br/></td> </tr><tr> <td><label for="nation">Country:</label></td> <td><input type="text" id="nation" name="nation"><br/></td> </tr><tr> <td><label for="screenshot">Picture:</label></td> <td><input type="file" name="screenshot" value="Choose image"><br/></td> </tr></table> </fieldset> <input type="submit" name="submit" value="Save"> </body></html> Okay so it doesnt update even tho you would expect it to. A good step at debugging would be to add echos or var_dumps to see which IFs are triggering and which arent. Its a really basic process, but you can try something like: if(isset($_SESSION['user_id'])) { echo 'User session is set<br>'; $id1=$_SESSION['user_id']; if(isset($_POST['submit'])) { echo 'Form is submitted<br>'; $dbc=mysqli_connect('localhost','root','','mismatch') (...) Do that on several key IF statements, to see where your code is going. The issue doesnt have to be lay in the PHP. Try it out and see how far your script actually goes.
-
Finding the accurate zip code based on IP Address
DaveyK replied to junejune's topic in Third Party Scripts
Moderns browsers support geolocation right? I imagine there is a JS solution for that? A browser will request the users location and the user can accept or deny.- 4 replies
-
- zip code
- geolocation
-
(and 1 more)
Tagged with:
-
I dont see your code in code blocks. So thats one thing you havent done. None of the things I said will actually solve anything. But it MAY help us understand your problem and give guidance (we wont solve your problem for you. Well sometimes we will.). REGARDLESS, I am completely missing your problem. What is the issue?!
-
- Please show your code in code blocks, identified by the "<>" icon on the top. - Also, you dont have to open and close your connection on every query. MySQL will use the last opened connection so you can just set it at the beginning of the file, and close it at the end of the file. (or in init/footer files respectively). - what happens if cloud changes his username? Huge loss of data. - You dont have to set new variables if your stuff is already available in a variable. Ask yourself: what do I want from this code anyway? You say it displays 3 times, which is correct according to the table. What do you want it to display then?
-
- Firstly, display your code in code tags, identified by the "<>" icon on the top - Second, make you have all your logic ABOVE the HTML. - Trim your code to the stuff that is relevant - Ask a question and tell us what is not working. - It would be wise to indent your code :/ this is so hard to read. Seriously, you arent even asking a question.
-
http://bit.ly/13xJUNS
-
Its actually NOT tedious at all. I use Less for everything, running a program call WinLess in the background. Every time I change a Less file, the Less gets compiled into a bootstrap.css file in the css folder automatically. Bootstrap.css is also minified! Couldnt be easier. Use it.
-
You could do a case, but why not process it in your code