![]() |
Personal Notes via PHP
So i know i just got help with some update settings from yall but this one is quite different in a way.
I am trying to have a personal notepad in the user/admin dashboard but for some reason it won't update like last time or read the data from the mysql database to post.. Full Code: http://pastie.org/471693 Code To Read & Post Data To Form: PHP Code:
PHP Code:
|
Let's do it one step at a time. Let's first clean up your query..
PHP Code:
|
not quite sure how i would do that as this is how i read to do it in a few tutorials i found on google :p
|
When I debug queries in .net, I use the following steps:
1. Output the formatted query that you are sending. That means you echo the exact same string you are giving the database. That can reveal potential errors that are in the variables. 2. Simulate a correct query in the database viewer. 3. Erase the query and re-write it from square one 4. Repeat I've only had to ask two questions regarding queries in the last year with this method (and don't say I am better with SQL, I have had to write extremely advanced queries I learned how to write ten minutes before). |
Quote:
|
Quote:
|
1. Worked Fine
2. First Had Errors Cause of MD5 Hashed Passwords 3. Rewrote without verifying the password as that seems to be what was causing it. So it worked. Final Code: PHP Code:
|
Quote:
I just have my own personal preference when it comes to queries. So it looks like yours was fine..but I like to use AND instead of && etc....stuff like that....no biggie... |
ah yes my friend told me to use && i dont quite know the big difference.
|
using AND over && is a matter of preference, I personally like && so I don't get AND or and confused with a string for some odd reason whilst scanning code.
|
Quote:
I like to go for readability. So AND instead of &&. OR instead of || etc...other than preference, I don't think SQL really cares which way you do it... I also like to make my SELECT statements capitalized and columns,tables lowercase like this: SELECT * FROM user WHERE user_id = 5; Again, just preference..... |
Quote:
*Except for BASIC, but that hardly counts |
Quote:
Oh come on....we all know English is the *universal language... hahaha....just kidding... :-P |
In PHP AND and OR operate under different precedence rules to || and &&.
http://uk3.php.net/manual/en/languag...precedence.php An example: PHP Code:
If you look at the precedence chart on php.net, you see that 'or' is lower down the list than '||' this means that it has lower precedence, this in itself isn't the issue however. The issue arises when you use it in conjunction with another operator, for example '='. '||' is higher in the list than 'or', so therefore any expression with '=' in it must be evaluated first, thus: PHP Code:
|
Quote:
In PHP, I always use '||', I never use OR or AND surprisingly so I hope that by using '||' and '&&', I won't ever run into any issues that spits out the wrong results... How come when something evals to true, you get 1, but when it evals to false, you don't get any output? I thought a '0' would be the output? The output of your code above would be: e: 1 f: |
| All times are GMT. The time now is 05:20 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0