I really appreciate your feedback! It has helped a lot and I have almost finished my website! The other thing is that from time to time, my email activation does not work... I didn't change anything in the database or php coding... weird
Thanks for your kind assistance here.. With regard to timestamp, if I set the attributes to on update current timestamp, will this only be updated whenever I update the sql database?
I may have asked before but if i have a table with many variables, should my variables be working if i assined it correctly? I don't have to use null right even though that null makes it easier
Hey guys! I am not sure if the following are correct when using prepared statement? Because the word limit is in red when I do this instead of green... ``` $sql = "SELECT id FROM categories WHERE id= ? LIMIT = ?"; $stmt = mysqli_stmt_init($conn); if (!mysqli_stmt_prepare($stmt, $sql)) { echo 'SQL error'; } else { mysqli_stmt_bind_param($stmt, "ii", $cid, $limit) mysqli_stmt_execute($stmt); ```
thanks Assad. you've done a great job of simplifying prepared statements! i ran into a minor problem, however, when i type your select, insert, update and delete statements exactly as you have them... such as: $query = "SELECT 'username', 'password' FROM 'users' WHERE 'username'=? AND 'password'=?"; the only way it will work on my godaddy, cpanel, shared hosting account is if i delete all of those single quotes around the table and fields inside of the double quotes. can you explain why your code obviously worked on your local server but not on mine?
Actually these are not single quotes. These are called back ticks and you can find it on your keyboard right underneath escape key. Let me know how it went. You are very welcome.
Also, just to further enhance my understanding of mysqli_fetch_assoc and mysqli_stmt_fetch.... I think in my other question, you mentioned that the mysqli_fetch_assoc is the most common way to fetch data from an array but I thought what we are doing now is just inserting information into the database in a non array format? I am confused as to whether I should use mysqli_stmt_fetch or not? thanks!
Prepared statement is the best option as far as the security is concerned. PHP mysqli extension provides us a lot of functions and we can choose the one best suites as per our need. mysqli_fetch_assoc() returns an associative array. Just print_r($result) and you will get the idea mysqli_fetch_array() returns hybrid array which is also associative and indexed mysqli_stmt_fetch() is self explanatory. Upon every execution of it stores results into binded result parameters.
I have watched some other videos where they use div class for an image element. Is this a good way to do it? Can I write something like div.image? How do you resize an image? would i use background-size? I can't get it to work using that element
As it requires a lot of text to write, it would be better if you read this thread: stackoverflow.com/questions/492809/when-to-use-img-vs-css-background-image
If I want to add a time in the user's database such as 00:01:50, should this be stored as an int or string? and how would I compare this in an if statement.. can i do.. if($time > 00:02:50). Would I have to use explode to get rid of this :?
Hello! Initially, I thought that by doing explode, you would add the array into just 1 column correct? I am not familiar but have tried with this code and it seems to work that it is adding two variables into two columns instead of just one? Is that the function of list function? list($category,$topic)=explode("|",$_POST['category']);
What is the difference between isset and $_session? From my understanding, I usually use isset when setting a form to determine if the form has been set? and session to check if there is a session?
This is weird... I have the following list items under but when I placed the div class called nav-login, it pushes the login form underneathe my nav bar.. However, if I removed it, then it works... is it possble to get the nav-login to lign up with my nav bar?
Home Primer Level Level 1 Level 2 Level 3 Signup Update Profile Reset Password Q/A Contact Us Donation Status Review Activate Email Bulletin
Watch my tutorials related to nav. Actually you lack basics that's why you stuck over and over again on everything. I would recommend you to improve your basics first.
Store the value on your server. In your database or session (it really depends upon your requirements), read the timer value on page load and start the timer in JavaScript. Don't forget to save the value of the timer in localStorage or sessionStorage.
I think it is working now but when you are inserting users into the database, do you need to fetch the $stmt in line 32? You got rid of bind result but can I also get rid of fetch? Also, does b mean boolean as in 0 = false and 1 = true? I can get my first if statement to update but not the second one..I would appreciate if someone could help me to get the rest of my if statements to update.. Can I use the header()?
I am confused with the div class because in some videos, they mentioned that you can have a div class before an img src but I tried doing that and it didn't work. It only works if I do something like this etc... In one of the forums, they mentioned not to use div class for images.... is this true?
Can't answer this question unless you share the source code with me. DO NOT SHARE THE SOURCE CODE DIRECTLY HERE. USE codepen.io or jsfiddle.net and share the link with me.
I am also trying to learn about animation-fill-mode but is it possible to let the animation go from start to the end of the page and then set the fill mode to center? I don't think this is possible though...
I left another message here but can't see it and hope i haven't double post but what is the difference between setting null and undefined in the database? If i set it as null in my database, i noticed that i don't have to declare the variable in my php.. is this also correct for undefined?
Can a div class be anyname? I have tried to name it primerdrum and match that with my css name but for some reason, it doesn't work... it only works if I give it a shorter name...
I don't know how you are doing things but, there should not be any issues. Just one thing you should keep in mine, the class name or the id selector name cannot be started with a number. For example: 1-div // this is incorrect since a class name or the id name should start with non numeric value
I have got a timer that can display the time when the user stops the timer and can output this in php. For some reason, I can't store it in the database and the format looks like this 00:01:42.. do i use timestamp?
Do you also need to use else after every if statement? Someone mentioned that for this code... if (!isset($_POST['submit'])) { } else {} Someone told me that I don't need to use else here for that statement..
Hey! How is it going? I am trying to learn about tables and border but when I am echoing out the border in php, it doesn't make a difference whether there is a border or not but I can see a difference in html. Also, can I add colspan in my tr tag because I can't get it to work in my tr tag, only in my th tag...
Hello! I got a table in my header.php, which is linked to all of my pages to make it uniform but I would like that table to be hidden in one of my pages, can I do this and must I use javascript?
depends upon your requirements. You can even hide the table with CSS or if you want to hide/show upon user interaction, you can put JavaScript into play
AssadUllahCh i guess i can also copy and paste that particular section and put in a separate file and to include it.. is there a way to exclude the file though?
Okay... I will learn more basic things first but if someone ask me to have a look at my php code and to compress it for them? Is it safe to do that and to give them the sql database?
Well, compressing the code will only reduce the file size and there won't be any impact on the performance. Giving somebody your source code + database depends upon requirements. For example, if you a working for a client and you haven't paid yet and there is no freelancing platform involved, I won't recommend you to hand it over the whole source code + database because there are changes he could disappear after taking the code from you and your hard work will be ended up in time waste.
This is really strange as my font awesome stars are still being displayed randomly and not in a horizontal straight line.... Do you have an email address, so that I can show you how it looks like? Could it be a CSS problem that my pictures are not lined up properly? how would I display them in CSS to be in a single straight line?
what is the difference between using this statement if ($row = mysqli_fetch_assoc($result)).. instead of while($row=mysqli_fetch_assoc($result)).. What is the difference here? Should it usually be a while loop here?
mysqli_fetch_assoc() returns a row from a fetched result set every time you call it. Returned data gets saved in the $row variable. If condition and while condition stay true as look as $row variable is not empty. The difference is clear, while is loop for repeating as long as the condition returns true and if statement is for one time execution. It can also put inside the loop body and by the way it all depends upon the logic.
I have the following code and I am trying to give the user a sticker everytime they enter something into the database.. This does work but how would I reset the counter? if they have already received 5 stickers and I want the sticker to start again at the beginning of a page, I tried to do something like this but it keeps looping through like the counter isn't resetting... for ($i = 1; $i
Incorrect logic. What you are doing is keep setting $i to 5. This is how this loop will be executed: If the value of $resultCheck is greater than 5, this will become an infinite loop. You can however set stickers in an array and use php random function to select a random sticker each time user inserts something in to database.
I have the following codes and from my understanding, does the loop begin with the while statement? I tried putting my codes that I don't want to loop through before the while and it works.... I thought that the loop starts at the for statement?
This is the code... if I do this, it will display the main title once, which is what I intended it.. I guess the while($row = mysqli_fetch_assoc($result))... is the start of a loop?
I have the following code and trying to style this in css: Should this be working? while ($row = mysqli_fetch_assoc($result)) { echo 'Welcome to your Update page '.$row['user_first'].' '.$row['user_last'].'!'; echo ''; In my CSS.. I have p.update_title {}
Hey Assad! I got the following table, this is part of my code but am trying to get the $id to be display on the url so that I can pass it to another page but can't seem to get it to work: echo '
I have done a similar thing to this code but for some reason, this code doesn't work here but it does work for my other section: echo ''; echo 'Welcome to PianoCourse101 '.$row['user_first'].' '.$row['user_last'].''; echo ''; echo '';
Hello! I have just finished my forum section by using the method but is it possible to do this inside my own forum? I like to tell the users to go to this link but tried using [url]bulletin.php[/url] which did not display the link....
Hello! What is the difference between display: block and diplay: inline-block? In some forums, some people told me to use display: block to put it in one line but I found that display:inline-block works and it didn't work when I used display: block
There are two main types of elements in HTML. 1 - Block level elements (which take up the whole page width) 2 - Inline element is the one which stays in a line and only takes up the space depending upon the content contained inside it. There are a lot of controls in CSS including the control to make an inline element behave like block level element and vice versa. An inline element does not accept vertical rules like height, margin-top. margin-bottom, padding-top and padding-bottom etc. Making it behaving like block level using display:block will make it accept vertical rules as well. The display:inline-block; allows inline and block level elements to put side by side plus it will also accept height and width.
So by using display:block should also put in in a line then but how come I can't put the following sentence in a line by doing it that way? Welcome to PianoCourse101 This is the CSS... div.header2_welcome h1 span { display:block}
One of my other questions was not shown here but can you do this with if statemnt? if ($subscriptionplan === 'Level 1' && $pricing_level1 === '') { header("Location: update.php?upgrade=level1pricenotselected"); exit(); } ... Can i have 3 variables because when i triedt this,it didn't work.. It only work if I have 2 or 4 variables such as: if ($subscriptionplan === 'Level 1' && $pricing_level1 === 'None' || $subscriptionplan === 'Level 1' && $pricing_level1 === '') { header("Location: update.php?upgrade=level1pricenotselected"); exit();
You need to wrap the OR comparisons in parenthesis. if ($subscriptionplan === 'Level 1' && ($pricing_level1 === 'None' || $subscriptionplan === 'Level 1' && $pricing_level1 === ''))
I have the following form with two buttons but I can' get my second if statement to work.. The submit button is linked to the form but it should take me to update.php submit error if not set... Here are my codes:
Choose a plan None Level 1 Level 2 Level 3
Choose a price plan for Level 1 None Monthly:$100 Yearly:$800
Choose a price plan for Level 2 None Monthly:$150 Yearly:$1300
Choose a price plan for Level 3 None Monthly:$200 Yearly:$1800
I am having some problems with my localhost at the moment and it keeps displaying the following message.. This page isn't working, redirectting too many times... I tried to change my index.php layout because is it true that you can't have html codes before any php header? I don't know what is causing this issue and kind of disappointed... I think the problem is with the redirect... because when I omit it, then it is working but I need to have this in my code....
For boolean you will be using the type 'i' as an integer. Don't forget to take a look at this reference: php.net/manual/en/mysqli-stmt.bind-param.php For timestamp, there are a lot of ways to handle it. For example: $stmt = mysqli_prepare($connection,'insert into foo (dt) values (?)'); $dt = '2009-04-30 10:09:00'; mysqli_stmt_bind_param($stmt, 's', $dt); mysqli_stmt_execute($stmt); If you want to store current timestamp, you can it like this: $stmt = mysqli_prepare($connection,'insert into foo (dt) values (NOW())'); Another way of doing this: $stmt = mysqli_prepare($connection,'insert into foo (dt) values (FROM_UNIXTIME(?))'); mysqli_stmt_bind_param($stmt, 's', $dt); And you can use the type 'i' to store a numeric epoch timestamp. mysqli_stmt_bind_param($stmt, 'i', $dt); Hope you got the idea.
Thanks for the reply... appreciate it! What is the difference between mysqli_stmt_get_result and mysqli_stmt_fetch? I have always been using the get_result and it seems to work...
I am also trying to display the user's information on the form if they refreshed the page and i know how to do this if the form sends information to itself but how do you do it when the form sends the information to another page
Hello! I got the following radio button and I thought that by doing if (!$resolve) {} should alert the user to make a choice of either a yes or no but for some reason, it will always say failed, even though that the user has selected an option. I got it to work by doing the following though... if ($resolve = '' ) {} but I thought the former should work: Here is just my first line of code: echo 'Has this been Resolved?YesNo
For some reason, it will always display that the variable has not been passed through? Perhaps I did not check it? I guess the logic here would be to process the form regardless of the error but to alert the user to input something and hence I should use if ($resolve = '') {}; is that the logic? I guess if (!$resolve) {} means that the variable is not passed through
Have you seen this code before? It is from mysql_query: Will this code work for prepared statement? The if statement does not make sense to me and I have an error because of that.. if (($result) && ($result2) && ($result3)) { header("Location: view_topic.php?id=".$cid."&tid=".$new_topic_id); } else { echo 'There was a problem'; }
I might have managed to get a countdown timer working but how do I alert the user their time result? var timer = ; // 1 minute timer.... var min = 0; var sec = 0; function startTimer() { min = parseInt(timer/60); sec = parseInt(timer%60); if(timer
I have the following basic code and I will try to use codepen next time but it doesn't support php.... In one of the tutorials, he uses object orienting but how can I get my $row to be echoed out in the html document with procedure? PHP QUIZZER
I have told you over and over again to learn the basics first. Can you directly echo out an array?? $arr = []; Can you do echo $arr; ???? YOU CAN'T SINCE ARRAY CONTAINS MORE THAN ONE VALUES ON SPECIFIC INDEXES AND THE $ROW VARIABLE IS ALSO AN ARRAY.
Is there also a problem with localhost? Has anyone encounter a problem where the database just stops working? I thought it was my code but then eventually, it does work again...
AssadUllahCh that makes sense but when it comes to choosing either s, i or b in prepared statement, which would you pick for timestamp? I find that string works
how do you redirect to the same page in php? When I do this, I keep getting the message, cannot modify header.. I guess that because I am sending this to the same page, the error pops up....
Hello! How do you use prepared statement for the following query with limit 1? $sql = "SELECT id FROM categories WHERE id= '".$cid."' LIMIT 1";.... When I do this, the word limit 1 appears in red! I tried to do this: $sql = "SELECT id FROM categories WHERE id= ?' LIMIT 1";
This should work: $sql = "SELECT id FROM categories WHERE id= ?' LIMIT 1"; And the following should also work: $sql = "SELECT id FROM categories WHERE id= ?' LIMIT ?"; Now you need to bind the parameter for LIMIT placeholder as well using the second method.
I have the following code and have done this in my css p.name{} and everything is working but for the color attribute. Even if I put the !important after it, it still doesn't work..... I have no idea why.. echo "Welcome to your Music Forum, ".$row['user_uid']."!"; This is the CSS: p.name { padding-left: 600px; position: relative; bottom: 20px; right: 40px; color:green; }
Take a look at your HTML structure carefully. It's incorrect. You are putting an anchor tag in the opening tag of the div and then you are putting the closing div tag without closing the anchor tag. Use HTML online validator to get the idea about html mistakes. I HAVE TOLD YOU OVER AND OVER AGAIN. LEARN THE BASICS FIRST. IT WON'T TAKE MUCH OF YOUR TIME. IF YOU FOLLOWED MY SUGGESTIONS, YOU WOULD HAVE A FAR BETTER UNDERSTANDING UNTIL NOW. THIS IS NOT THE RIGHT WAY TO GO.
I have the following form action and like to do some error handlers.... I am trying to see if the user has selected a price or not and I am trying to do the following but it doesn't seem to work in one line of if statement... Here is my form action and php
Choose a plan None Level 1 Level 2 Level 3
Choose a price plan for Level 1 None Monthly:$100 Yearly:$800
Choose a price plan for Level 2 None Monthly:$150 Yearly:$1300
Choose a price plan for Level 3 None Monthly:$200 Yearly:$1800
Upgrade Plan Email invoice if ($subscriptionplan === 'Level 1' && $pricing_level1 === 'None' || $pricing_level1 === '') { header("Location: update.php?upgrade=level1pricenotselected"); exit(); } else if ($subscriptionplan === 'Level 2' && $pricing_level2 === 'None' || $pricing_level2 === '') { header("Location: uupdate.php?upgrade=level2pricenotselected"); exit(); } Can If do multiple comparisons? if I select Level 2, it still takes me to level1 header... For some reason, these lines do work though... if ($subscriptionplan === 'Level 1' && $pricing_level1 === 'None' || $subscriptionplan === 'Level 1' && $pricing_level1 === '') { header("Location: update.php?upgrade=level1pricenotselected"); exit(); } else { if($subscriptionplan === 'Level 2' && $pricing_level2 === 'None' || $subscriptionplan === 'Level 2' && $pricing_level2 === '') { header("Location: update.php?upgrade=level2pricenotselected"); exit(); } else { if($subscriptionplan === 'Level 3' && $pricing_level3 === 'None' || $subscriptionplan === 'Level 3' && $pricing_level3 ==='') { header("Location: update.php?upgrade=level3pricenotselected"); exit(); } }
You need to understand operator precedence and associativity. The && and || operators are left associative. if ($subscriptionplan === 'Level 1' && $pricing_level1 === 'None' || $pricing_level1 === '') The above comparison becomes ($subscriptionplan === 'Level 1' && $pricing_level1 === 'None' ) OR ($pricing_level1 === '') So, ($subscriptionplan === 'Level 1' && $pricing_level1 === 'None' ) is returning false and ($pricing_level1 === '') is returning true. That's the reason you are taken to level1 header. You also need to handle the precedence while performing such a comparison. Correct version: if ($subscriptionplan === 'Level 1' && ($pricing_level1 === 'None' || $pricing_level1 === ''))
I think I have managed to understand how to set my variables to null but I am just wondering, can you do an email activation if you set it to null? I tried it but it won't let me activate my email, however, if I unset null, then it works....What is the meaning of null? I just find it hard to understand fully how it works...
It's all about logic and logic can be written as per our needs. I think you got some table filed name 'activation' and you set its default value to NULL and in your case NULL means the user is not activated. To search for a NULL value in SQL, you can query the database table like this: SELECT * FROM tablename WHERE activation IS NULL;
For some reason, if I set all other columns with unknown variables to null, then it works... Is it common to use null in this way? So, I have to use your query as what you typed above? SELECT* FROM tablename WHERE activation IS NULL? and SELECT* FROM tablename WHERE activation = NULL?
This is strange because I thought that the sql insert function should allow me to insert more than one records but it is only inserting one record whenever I send a ticket system contact...
Well... seems like are not good at logic building. You can get it done this way. foreach($values as $value){ mysqli_stmt_bind_param($stmt, 's', $value); mysqli_stmt_execute($stmt); } If you got a multidimensional array, you can do something like this: $values = [ ['name' => 'John Doe', 'email' => 'john@example.com'] ['name' => 'Sally', 'email' => 'sally@example.com'] ['name' => 'Bella', 'email' => 'bella@example.com'] ]; Now you can loop through this array but remember, don't forget to store the values in specific variables since a variable reference is required while binding params. foreach($values as $value){ $name = $value['name']; $email = $value['email']; mysqli_stmt_bind_param($stmt, 'ss', $name, $email); mysqli_stmt_execute($stmt); } There are other ways as well. I tried to keep it simple just to give you an idea.
Well, It's not mandatory to use auto-increment for ids. Following are the few more options for you. Set the data type of your ID filed to varchar: 1 - Use PHP time() function to generate the value of user id. 2 - Use PHP random_int() function to generate the value of user id. 3 - Use PHP random_bytes() function to generate the value of user id. 4 - Use PHP openssl_random_pseudo_bytes() function to generate the value of user id. Don't forget to check if the ID already exists in the database to avoid duplication.
Tryout this query in PHPMyAdmin SQL editor and if it still does not work, You can generate a query using update button located underneath SQL query editor. Use that query and there won't be any issues.
I am trying to resize my picture profile but for some reason, it will only work if I add a width and height here.. echo ""; if ($rowImg['status'] == 0) { echo ""; } else { echo ""; } but when it doesn't work in my CSS code... if ($rowImg['status'] == 0) { echo ""; } else { echo ""; } .profile_picture { width: 100px; height: 50px; }
It's better to assign a class to modify the styles dynamically. If you think some specific style is not getting applied, just increase it's priority by appending !important right after your desired property. For example: .profile_picture { width: 100px !important; height: 50px !important; } This will apply this width and height no matter what.
I tried to add the !important but it is still showing as.. I can't paste it here... do you have an email so that I can send the picture to you? Can you add padding to move the pictures around?
I tried that but not sure why it is not working... Do you have an email address so that I can show you how it looks like on my browser? Also, are you familiar with font awesome? It has a class such as "fas far-star", would I need to do something like . fa far-start {}
Why do you have to use bind param? Is this only used if you don't select all variables? when I selected all of my variables by doing *, I don't have to bind them...
Binding result variables only makes sense if you are selecting the specific columns. If you want to select the whole table, you don't need to bind result. Take this example: mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); while ($row = mysqli_fetch_array($result, MYSQLI_NUM)){ // deal with results here... }
Are you familiar with CSS and the wrapper? I have included more unordered lists and it seems to be affecting my wrapper but if I remove the wrapper from the CSS, then it does work.... What is wrapper for? Also, I have been using mysqli_fetch_assoc all along and I don't think my sql queries is an array... is it just storing it as an array?
wrapper? I believe you are talking about the class name or id name if I get it right. Class names allow you to apply same styles on one or more elements whereas the id should be unique. For example: You got a job in police and you will be given the same uniform as your colleagues. This is where the class name comes into play. Unlike the class, more than one element cannot have the same id. // this is an error which browser won't show you but HTML validator can since the same it is assigned to both of the div tags. // this is correct since both div tags have same class names and now you can apply same styles to more than one elements with just a common css code snippet. In your case, you want to apply different styles to different elements but you are giving them the same selector name "wrapper" and by the way "wrapper" is just a name which you assigned to it. It could be anything. it's not mandatory to use "wrapper". Rule of thumb is to give your elements readable class names and id names which makes some sense. For example, the name 'container' or 'wrapper' gives you the idea the element is containing other element(s).
This is the first time that I have come across a < sign in sql query. What does the following query mean? because most of the time, I have only used = sign...: $sql = "SELECT * FROM users WHERE admin < ".$row['admin']."+1;"; mean?
Merv its just a comparison operator which is used to check whether some certain number is less than some threshold. Say you wanted to select users age less than 18. SELECT * FROM users WHERE age
I am trying to do this this function and it seems to be working only if I get rid of my background color of grey... I tried to change color but no matter which color I pick, it doesn't seem to help.. If I get rid fdof the header.php, then it does work.. I think the problem is in my css.. I will also include my css coding...
I managed to get it to work but the strange thing is that some of my CSS does not work in chrome but is workinng IE. I wonder if there might be a problem with some free web hosting as well with css
I also have a feeling that this is incorrect: $sql2 = "SELECT * FROM topics WHERE category_id= '".$cid."' ORDER BY topic_reply_date DESC"; $stmt = mysqli_stmt_init($conn);
I thought that chrome browser should be more reliable than IE but my IE is responding better to the CSS than chrome. I am trying to do a drop down menu but for some reason, my display: block is not working for my nav ul li a {}... I had to use padding-top instead to line in the middle.... For this line of code.. it doesn't work; My header nav ul li a {} doesn't work.. so I have to add padding-top in nav ul li {} The codepen link is: codepen.io/mervin-lee/pen/RBWEXP
I got the full code here and just wondering if the following if statements do make sense for me? I pasted the php code in the html part of codepen though: codepen.io/mervin-lee/pen/LBWYdM
I am also trying to get this loop to work and I can get it working and to display the id properly if using$row['id'] but can I do it by using $x? as shown here because it doesn't work: while ($row = mysqli_fetch_assoc($result)) { for ($x = 1; $x
You lack basics of HTML, CSS and PHP. I would recommend you to work on your basics first. Learn how all the loops work in PHP. What are the arrays. How to manipulate arrays etc.
mysqli_fetch_assoc() this function returns ASSOCIATIVE ARRAY not INDEXED ARRAY. So, you need to use mysqli_fetch_array() instead of it. This function will return a hybrid array containing index numbers and index names as well. Don't forget to keep debugging your code using print_r() or var_dump() functions. Inside your while loop, if you do this: print_r($row); It will show you the array, it's keys and values as well. This way you will get the idea how you can handle the result.
I am trying to learn about paypal and ipn simulator and was watching another video by passive income but I can' get my listener.php to work... Have you done this before? Here is my code for listener.php but I have a domain with ihostfull: ihostfull/pianocourse101/index.php but when I put this url in the ipn simulator, it said handshake not verify... I noticed that this domain does not start with http: or www...
For some reason, the reset stylesheet from html5 doctor is causing my drop down menu issue.. I have got the following drop down meny and here is the code from code pen.... codepen.io/mervin-lee/pen/oMjVyp
Great tutorial thanks
I really appreciate your feedback! It has helped a lot and I have almost finished my website! The other thing is that from time to time, my email activation does not work... I didn't change anything in the database or php coding... weird
Thanks for your kind assistance here.. With regard to timestamp, if I set the attributes to on update current timestamp, will this only be updated whenever I update the sql database?
Whenever you will query that particular table. You are welcome.
I may have asked before but if i have a table with many variables, should my variables be working if i assined it correctly? I don't have to use null right even though that null makes it easier
Hey guys!
I am not sure if the following are correct when using prepared statement? Because the word limit is in red when I do this instead of green...
```
$sql = "SELECT id FROM categories WHERE id= ? LIMIT = ?";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
echo 'SQL error';
} else {
mysqli_stmt_bind_param($stmt, "ii", $cid, $limit)
mysqli_stmt_execute($stmt);
```
thanks Assad. you've done a great job of simplifying prepared statements! i ran into a minor problem, however, when i type your select, insert, update and delete statements exactly as you have them... such as:
$query = "SELECT 'username', 'password' FROM 'users' WHERE 'username'=? AND 'password'=?";
the only way it will work on my godaddy, cpanel, shared hosting account is if i delete all of those single quotes around the table and fields inside of the double quotes.
can you explain why your code obviously worked on your local server but not on mine?
Actually these are not single quotes. These are called back ticks and you can find it on your keyboard right underneath escape key. Let me know how it went.
You are very welcome.
Also, just to further enhance my understanding of mysqli_fetch_assoc and mysqli_stmt_fetch.... I think in my other question, you mentioned that the mysqli_fetch_assoc is the most common way to fetch data from an array but I thought what we are doing now is just inserting information into the database in a non array format? I am confused as to whether I should use mysqli_stmt_fetch or not? thanks!
Prepared statement is the best option as far as the security is concerned. PHP mysqli extension provides us a lot of functions and we can choose the one best suites as per our need.
mysqli_fetch_assoc() returns an associative array. Just print_r($result) and you will get the idea
mysqli_fetch_array() returns hybrid array which is also associative and indexed
mysqli_stmt_fetch() is self explanatory. Upon every execution of it stores results into binded result parameters.
I have watched some other videos where they use div class for an image element. Is this a good way to do it? Can I write something like div.image? How do you resize an image? would i use background-size? I can't get it to work using that element
As it requires a lot of text to write, it would be better if you read this thread: stackoverflow.com/questions/492809/when-to-use-img-vs-css-background-image
If I want to add a time in the user's database such as 00:01:50, should this be stored as an int or string? and how would I compare this in an if statement.. can i do.. if($time > 00:02:50). Would I have to use explode to get rid of this :?
Is prepared statment just to protect database? Must I use htmlentities for login form if I have enough error handlers?
Hello! Initially, I thought that by doing explode, you would add the array into just 1 column correct? I am not familiar but have tried with this code and it seems to work that it is adding two variables into two columns instead of just one? Is that the function of list function?
list($category,$topic)=explode("|",$_POST['category']);
I am also wondering if you know where to get svg codes for musical notes and how to use them?
What is the difference between isset and $_session? From my understanding, I usually use isset when setting a form to determine if the form has been set? and session to check if there is a session?
Check these links to get the answer to your question:
php.net/manual/en/function.isset.php
php.net/manual/en/reserved.variables.session.php
This is weird... I have the following list items under but when I placed the div class called nav-login, it pushes the login form underneathe my nav bar.. However, if I removed it, then it works... is it possble to get the nav-login to lign up with my nav bar?
Home
Primer Level
Level 1
Level 2
Level 3
Signup
Update Profile
Reset Password
Q/A
Contact Us
Donation
Status
Review
Activate Email
Bulletin
<
Watch my tutorials related to nav. Actually you lack basics that's why you stuck over and over again on everything. I would recommend you to improve your basics first.
Hi... how do you do a simple countdown timer with php? I guess i would need javascript, do you have a timer that I can use?
Store the value on your server. In your database or session (it really depends upon your requirements), read the timer value on page load and start the timer in JavaScript. Don't forget to save the value of the timer in localStorage or sessionStorage.
I think it is working now but when you are inserting users into the database, do you need to fetch the $stmt in line 32? You got rid of bind result but can I also get rid of fetch?
Also, does b mean boolean as in 0 = false and 1 = true?
I can get my first if statement to update but not the second one..I would appreciate if someone could help me to get the rest of my if statements to update.. Can I use the header()?
It should work if you are sure enough that you are using correct file path to your database file.
I am confused with the div class because in some videos, they mentioned that you can have a div class before an img src but I tried doing that and it didn't work. It only works if I do something like this etc... In one of the forums, they mentioned not to use div class for images.... is this true?
Can't answer this question unless you share the source code with me. DO NOT SHARE THE SOURCE CODE DIRECTLY HERE. USE codepen.io or jsfiddle.net and share the link with me.
I am also trying to learn about animation-fill-mode but is it possible to let the animation go from start to the end of the page and then set the fill mode to center? I don't think this is possible though...
I left another message here but can't see it and hope i haven't double post but what is the difference between setting null and undefined in the database? If i set it as null in my database, i noticed that i don't have to declare the variable in my php.. is this also correct for undefined?
Can a div class be anyname? I have tried to name it primerdrum and match that with my css name but for some reason, it doesn't work... it only works if I give it a shorter name...
I don't know how you are doing things but, there should not be any issues. Just one thing you should keep in mine, the class name or the id selector name cannot be started with a number.
For example:
1-div // this is incorrect since a class name or the id name should start with non numeric value
I have got a timer that can display the time when the user stops the timer and can output this in php. For some reason, I can't store it in the database and the format looks like this 00:01:42.. do i use timestamp?
should I get rid of that if statements? everything seems to be working in my database...
Do you also need to use else after every if statement? Someone mentioned that for this code... if (!isset($_POST['submit'])) {
} else {}
Someone told me that I don't need to use else here for that statement..
It all depends upon one's requirements.
Also, with prepared statement, what does blog mean? text? if I set my database to using text, must it be blog or string?
There's nothing like blog. That's is blob which you are talking about. Blob allows you to store data in binary format which includes files n stuff.
Hey! How is it going? I am trying to learn about tables and border but when I am echoing out the border in php, it doesn't make a difference whether there is a border or not but I can see a difference in html. Also, can I add colspan in my tr tag because I can't get it to work in my tr tag, only in my th tag...
you need to learn CSS precedence.
Hello! I got a table in my header.php, which is linked to all of my pages to make it uniform but I would like that table to be hidden in one of my pages, can I do this and must I use javascript?
depends upon your requirements. You can even hide the table with CSS or if you want to hide/show upon user interaction, you can put JavaScript into play
AssadUllahCh i guess i can also copy and paste that particular section and put in a separate file and to include it.. is there a way to exclude the file though?
Do you also know of any good free domain name ending with .com?
nope. i dont know any
Okay... I will learn more basic things first but if someone ask me to have a look at my php code and to compress it for them? Is it safe to do that and to give them the sql database?
Well, compressing the code will only reduce the file size and there won't be any impact on the performance. Giving somebody your source code + database depends upon requirements. For example, if you a working for a client and you haven't paid yet and there is no freelancing platform involved, I won't recommend you to hand it over the whole source code + database because there are changes he could disappear after taking the code from you and your hard work will be ended up in time waste.
This is really strange as my font awesome stars are still being displayed randomly and not in a horizontal straight line.... Do you have an email address, so that I can show you how it looks like? Could it be a CSS problem that my pictures are not lined up properly? how would I display them in CSS to be in a single straight line?
Use codepen.io or jsfiddle.net to share the code.
what is the difference between using this statement if ($row = mysqli_fetch_assoc($result)).. instead of while($row=mysqli_fetch_assoc($result)).. What is the difference here? Should it usually be a while loop here?
mysqli_fetch_assoc() returns a row from a fetched result set every time you call it. Returned data gets saved in the $row variable. If condition and while condition stay true as look as $row variable is not empty. The difference is clear, while is loop for repeating as long as the condition returns true and if statement is for one time execution. It can also put inside the loop body and by the way it all depends upon the logic.
I have the following code and I am trying to give the user a sticker everytime they enter something into the database.. This does work but how would I reset the counter? if they have already received 5 stickers and I want the sticker to start again at the beginning of a page, I tried to do something like this but it keeps looping through like the counter isn't resetting...
for ($i = 1; $i
Incorrect logic. What you are doing is keep setting $i to 5.
This is how this loop will be executed:
If the value of $resultCheck is greater than 5, this will become an infinite loop. You can however set stickers in an array and use php random function to select a random sticker each time user inserts something in to database.
Is there a way that i can send a picture of my screen shot? I can't do it here
Yes in my facebook group. Get the link from about section of my channel.
I have the following codes and from my understanding, does the loop begin with the while statement? I tried putting my codes that I don't want to loop through before the while and it works.... I thought that the loop starts at the for statement?
show me the code
This is the code... if I do this, it will display the main title once, which is what I intended it.. I guess the while($row = mysqli_fetch_assoc($result))... is the start of a loop?
I have the following code and trying to style this in css: Should this be working?
while ($row = mysqli_fetch_assoc($result)) {
echo 'Welcome to your Update page '.$row['user_first'].' '.$row['user_last'].'!';
echo '';
In my CSS.. I have p.update_title {}
Come on man. Spend few days learning the basics first.
Hey Assad! I got the following table, this is part of my code but am trying to get the $id to be display on the url so that I can pass it to another page but can't seem to get it to work:
echo '
Category';
echo 'Pick a Category';
while($row = mysqli_fetch_assoc($result)) {
$id = $row['id'];
echo ''.$row['category'].'';
}
I have done a similar thing to this code but for some reason, this code doesn't work here but it does work for my other section:
echo '';
echo 'Welcome to PianoCourse101 '.$row['user_first'].' '.$row['user_last'].'';
echo '';
echo '';
just right click your browser, copy your source code and host it at codepen.io or jsfiddle.net and share the link with me.
Can i use the phpmy query editor with variables? I have prepared statement
NOPE
Without variables and by the way It won't take so much of your time.
Hello! I have just finished my forum section by using the method but is it possible to do this inside my own forum? I like to tell the users to go to this link but tried using [url]bulletin.php[/url] which did not display the link....
Should this code be working on localhost?
How can I do something like this with prepared statement?
You can do something like this:
$sql = "UPDATE viewcounter
SET views = views+1
WHERE id = ?
";
Hello! What is the difference between display: block and diplay: inline-block? In some forums, some people told me to use display: block to put it in one line but I found that display:inline-block works and it didn't work when I used display: block
There are two main types of elements in HTML.
1 - Block level elements (which take up the whole page width)
2 - Inline element is the one which stays in a line and only takes up the space depending upon the content contained inside it.
There are a lot of controls in CSS including the control to make an inline element behave like block level element and vice versa.
An inline element does not accept vertical rules like height, margin-top. margin-bottom, padding-top and padding-bottom etc. Making it behaving like block level using display:block will make it accept vertical rules as well.
The display:inline-block; allows inline and block level elements to put side by side plus it will also accept height and width.
So by using display:block should also put in in a line then but how come I can't put the following sentence in a line by doing it that way?
Welcome to PianoCourse101
This is the CSS... div.header2_welcome h1 span { display:block}
I can only get it to work with display:inline-block
You did not understand my reply actually. You should read this article css-tricks.com/almanac/properties/d/display/
One of my other questions was not shown here but can you do this with if statemnt? if ($subscriptionplan === 'Level 1' && $pricing_level1 === '') {
header("Location: update.php?upgrade=level1pricenotselected");
exit();
} ... Can i have 3 variables because when i triedt this,it didn't work..
It only work if I have 2 or 4 variables such as:
if ($subscriptionplan === 'Level 1' && $pricing_level1 === 'None' || $subscriptionplan === 'Level 1' && $pricing_level1 === '') {
header("Location: update.php?upgrade=level1pricenotselected");
exit();
You need to wrap the OR comparisons in parenthesis.
if ($subscriptionplan === 'Level 1' && ($pricing_level1 === 'None' || $subscriptionplan === 'Level 1' && $pricing_level1 === ''))
I am also wondering, how do those people make their own vpn programs like windscribe etc?
I have the following form with two buttons but I can' get my second if statement to work.. The submit button is linked to the form but it should take me to update.php submit error if not set... Here are my codes:
Choose a plan
None
Level 1
Level 2
Level 3
Choose a price plan for Level 1
None
Monthly:$100
Yearly:$800
Choose a price plan for Level 2
None
Monthly:$150
Yearly:$1300
Choose a price plan for Level 3
None
Monthly:$200
Yearly:$1800
Upgrade Plan
Email invoice
Upload Document
if(isset($_POST['upload'])) {
header("Location: upload.php");
exit();
} else {
if (!isset($_POST['submit'])) {
header("Location: update.php?submit=error");
exit();
} else {
include_once 'includes/dbh.php';
$subscriptionplan = $_POST['subscriptionplan'];
$email = $_SESSION['u_email'];
$pricing_level1 = $_POST['pricing_level1'];
$pricing_level2 = $_POST['pricing_level2'];
$pricing_level3 = $_POST['pricing_level3'];
Set values to your submit buttons as well. The if conditions are expecting some values.
Upgrade Plan
Email invoice
Upload Document
I have managed to get the following timer to work but how would I echo the timer out or save it in the session?
Stopwatch
00:00:00
var status =0;
var time = 0;
function start() {
status = 1;
document.getElementById("startBtn").disabled = true;
timer();
}
function stop() {
status = 0;
document.getElementById("startBtn").disabled = false;
}
function reset() {
status = 0;
time = 0;
document.getElementById("startBtn").disabled = false;
document.getElementById("timerLabel").innerHTML = "00:00:00";
}
function timer() {
if (status == 1) {
setTimeout(function() {
time++;
var min = Math.floor(time/100/60);
var sec = Math.floor(time/100);
var mSec = time % 100;
if(min < 10) {
min = "0" + min;
}
if (sec >= 60) {
sec = sec % 60;
}
if (sec < 10) {
sec = "0" + sec;
}
document.getElementById("timerLabel").innerHTML = min + ":" + sec + ":" + mSec;
timer();
}, 10);
}
}
DO NOT SHARE YOUR CODE HERE. USE jsfiddle.net or codepen.io to share your code.
sorry, i forgot but how do I get the link? I can't find the link from codepen
I think i got it... I hope that this is the correct link....codepen.io/mervin-lee/pen/WKQGqZ
I am having some problems with my localhost at the moment and it keeps displaying the following message.. This page isn't working, redirectting too many times... I tried to change my index.php layout because is it true that you can't have html codes before any php header? I don't know what is causing this issue and kind of disappointed... I think the problem is with the redirect... because when I omit it, then it is working but I need to have this in my code....
Problem with the redirect.
AssadUllahCh yup but how do i solve the problem?
I have got it working now but just to clarify, is b = boolean? as in true or falst and which interger should i give my timestamp?
For boolean you will be using the type 'i' as an integer. Don't forget to take a look at this reference: php.net/manual/en/mysqli-stmt.bind-param.php
For timestamp, there are a lot of ways to handle it.
For example:
$stmt = mysqli_prepare($connection,'insert into foo (dt) values (?)');
$dt = '2009-04-30 10:09:00';
mysqli_stmt_bind_param($stmt, 's', $dt);
mysqli_stmt_execute($stmt);
If you want to store current timestamp, you can it like this:
$stmt = mysqli_prepare($connection,'insert into foo (dt) values (NOW())');
Another way of doing this:
$stmt = mysqli_prepare($connection,'insert into foo (dt) values (FROM_UNIXTIME(?))');
mysqli_stmt_bind_param($stmt, 's', $dt);
And you can use the type 'i' to store a numeric epoch timestamp.
mysqli_stmt_bind_param($stmt, 'i', $dt);
Hope you got the idea.
Thanks for the reply... appreciate it! What is the difference between mysqli_stmt_get_result and mysqli_stmt_fetch? I have always been using the get_result and it seems to work...
Thanks for the reply but how would I insert two queries? Would I need to do a join query because that seems complicated....
AssadUllahCh and what is the meaning of blob? Is this text? If i set text instead of varchar... should i use blob?
I am also trying to display the user's information on the form if they refreshed the page and i know how to do this if the form sends information to itself but how do you do it when the form sends the information to another page
Hello! I got the following radio button and I thought that by doing if (!$resolve) {} should alert the user to make a choice of either a yes or no but for some reason, it will always say failed, even though that the user has selected an option. I got it to work by doing the following though... if ($resolve = '' ) {} but I thought the former should work: Here is just my first line of code:
echo 'Has this been Resolved?YesNo
For some reason, it will always display that the variable has not been passed through? Perhaps I did not check it? I guess the logic here would be to process the form regardless of the error but to alert the user to input something and hence I should use if ($resolve = '') {}; is that the logic? I guess if (!$resolve) {} means that the variable is not passed through
Bro do u have crud operation with this query ?
Here you go: ruclips.net/video/k8DIHwBgpnA/видео.html
sir can i have 3 prepared statement in one page? like two select and one update? because I'm encountering multiple errors
You need to create a separate statement for each query.
Have you seen this code before? It is from mysql_query: Will this code work for prepared statement? The if statement does not make sense to me and I have an error because of that..
if (($result) && ($result2) && ($result3)) {
header("Location: view_topic.php?id=".$cid."&tid=".$new_topic_id);
} else {
echo 'There was a problem';
}
Just copy this code mysql_query and paste it on google and type php.net. There you will get answer to your question.
how do you make a text align on both sides?
??
AssadUllahCh i tried text justify but the right side doesn't look like a block
I might have managed to get a countdown timer working but how do I alert the user their time result?
var timer = ; // 1 minute timer....
var min = 0;
var sec = 0;
function startTimer() {
min = parseInt(timer/60);
sec = parseInt(timer%60);
if(timer
Have you received the link?
You should make a video on how to implement paypal ipn simulator
will do it for sure.
I have the following basic code and I will try to use codepen next time but it doesn't support php.... In one of the tutorials, he uses object orienting but how can I get my $row to be echoed out in the html document with procedure?
PHP QUIZZER
PHP Quizzer
Question 1 of 5
Bar Line
Double Bar Line
Triple Bar Line
Bar
I have told you over and over again to learn the basics first. Can you directly echo out an array??
$arr = [];
Can you do echo $arr; ????
YOU CAN'T SINCE ARRAY CONTAINS MORE THAN ONE VALUES ON SPECIFIC INDEXES AND THE $ROW VARIABLE IS ALSO AN ARRAY.
AssadUllahCh thanks.. i knew it wasn't quite right but in the video.. i guess he didn't declare it
Is there also a problem with localhost? Has anyone encounter a problem where the database just stops working? I thought it was my code but then eventually, it does work again...
Reinstall your localhost server stack.
I am also wondering but dates such as timestamp,, is it considered a string? because when I changed it into integer, it doesn't work....
It's better to store timestamp as a timestamp in the database instead of a string.
AssadUllahCh that makes sense but when it comes to choosing either s, i or b in prepared statement, which would you pick for timestamp? I find that string works
Do you know of any free vpns? I used to use okay freedom but need another code for it...
how do you create a countdown timer in php? and CSS??
Will do a tutorial on it as soon as I get some time.
thanks but I did manage to get my bottom timer to work but how would I echo out the timer that the user has got once they stopped the clock?
how do you redirect to the same page in php? When I do this, I keep getting the message, cannot modify header.. I guess that because I am sending this to the same page, the error pops up....
You can do something like this: header("Location: " . "" . $_SERVER['HTTP_HOST'] . $location);
thanks.... I have found out that I can also use the meta tag? that also works!
Hello! How do you use prepared statement for the following query with limit 1?
$sql = "SELECT id FROM categories WHERE id= '".$cid."' LIMIT 1";.... When I do this, the word limit 1 appears in red! I tried to do this:
$sql = "SELECT id FROM categories WHERE id= ?' LIMIT 1";
This should work: $sql = "SELECT id FROM categories WHERE id= ?' LIMIT 1";
And the following should also work:
$sql = "SELECT id FROM categories WHERE id= ?' LIMIT ?";
Now you need to bind the parameter for LIMIT placeholder as well using the second method.
AssadUllahCh thanks and is the word limit 1 in single or double quote?
Thanks but you have a single quotation mark after ?... is that a mistake?
This is interesting, so you don't need to have an equal sign for limit?
I have the following code and have done this in my css p.name{} and everything is working but for the color attribute. Even if I put the !important after it, it still doesn't work..... I have no idea why..
echo "Welcome to your Music Forum, ".$row['user_uid']."!";
This is the CSS:
p.name {
padding-left: 600px;
position: relative;
bottom: 20px;
right: 40px;
color:green;
}
Take a look at your HTML structure carefully. It's incorrect. You are putting an anchor tag in the opening tag of the div and then you are putting the closing div tag without closing the anchor tag. Use HTML online validator to get the idea about html mistakes.
I HAVE TOLD YOU OVER AND OVER AGAIN. LEARN THE BASICS FIRST. IT WON'T TAKE MUCH OF YOUR TIME. IF YOU FOLLOWED MY SUGGESTIONS, YOU WOULD HAVE A FAR BETTER UNDERSTANDING UNTIL NOW. THIS IS NOT THE RIGHT WAY TO GO.
AssadUllahCh thanks and i will learn the basic first, then i should be able to pick up mistakes made in youtube videos... thanks
Hi.. have you managed to watch that video on how to implement ipn by passing code income? I left a message about how to get my listerner.php to work
Can I show you the video?
I am desperately trying to get this to work... thanks!
I'm extremely busy these days and I could not get time to check that nor I'm able to do videos for now.
I understand but would appreciate if you could check that video for me because I am up to that stage now of implementing paypal..
I have the following form action and like to do some error handlers.... I am trying to see if the user has selected a price or not and I am trying to do the following but it doesn't seem to work in one line of if statement... Here is my form action and php
Choose a plan
None
Level 1
Level 2
Level 3
Choose a price plan for Level 1
None
Monthly:$100
Yearly:$800
Choose a price plan for Level 2
None
Monthly:$150
Yearly:$1300
Choose a price plan for Level 3
None
Monthly:$200
Yearly:$1800
Upgrade Plan
Email invoice
if ($subscriptionplan === 'Level 1' && $pricing_level1 === 'None' || $pricing_level1 === '') {
header("Location: update.php?upgrade=level1pricenotselected");
exit();
} else if
($subscriptionplan === 'Level 2' && $pricing_level2 === 'None' || $pricing_level2 === '') {
header("Location: uupdate.php?upgrade=level2pricenotselected");
exit();
}
Can If do multiple comparisons? if I select Level 2, it still takes me to level1 header...
For some reason, these lines do work though...
if ($subscriptionplan === 'Level 1' && $pricing_level1 === 'None' || $subscriptionplan === 'Level 1' && $pricing_level1 === '') {
header("Location: update.php?upgrade=level1pricenotselected");
exit();
} else {
if($subscriptionplan === 'Level 2' && $pricing_level2 === 'None' || $subscriptionplan === 'Level 2' && $pricing_level2 === '') {
header("Location: update.php?upgrade=level2pricenotselected");
exit();
} else {
if($subscriptionplan === 'Level 3' && $pricing_level3 === 'None' || $subscriptionplan === 'Level 3' && $pricing_level3 ==='') {
header("Location: update.php?upgrade=level3pricenotselected");
exit();
}
}
You need to understand operator precedence and associativity. The && and || operators are left associative.
if ($subscriptionplan === 'Level 1' && $pricing_level1 === 'None' || $pricing_level1 === '')
The above comparison becomes ($subscriptionplan === 'Level 1' && $pricing_level1 === 'None' ) OR ($pricing_level1 === '')
So, ($subscriptionplan === 'Level 1' && $pricing_level1 === 'None' ) is returning false and ($pricing_level1 === '') is returning true. That's the reason you are taken to level1 header. You also need to handle the precedence while performing such a comparison.
Correct version:
if ($subscriptionplan === 'Level 1' && ($pricing_level1 === 'None' || $pricing_level1 === ''))
Appreciate the help! You are very good in explaining things! Keep up the good work my friend!
I think I have managed to understand how to set my variables to null but I am just wondering, can you do an email activation if you set it to null? I tried it but it won't let me activate my email, however, if I unset null, then it works....What is the meaning of null? I just find it hard to understand fully how it works...
It's all about logic and logic can be written as per our needs. I think you got some table filed name 'activation' and you set its default value to NULL and in your case NULL means the user is not activated.
To search for a NULL value in SQL, you can query the database table like this:
SELECT * FROM tablename WHERE activation IS NULL;
This query will select all rows from your where the value of activation field is null.
So, should I be able to activate when set it to null?
So, I guess my query was wrong... thanks... appreciate the assistance!
For some reason, if I set all other columns with unknown variables to null, then it works... Is it common to use null in this way? So, I have to use your query as what you typed above? SELECT* FROM tablename WHERE activation IS NULL? and SELECT* FROM tablename WHERE activation = NULL?
This is strange because I thought that the sql insert function should allow me to insert more than one records but it is only inserting one record whenever I send a ticket system contact...
Well... seems like are not good at logic building. You can get it done this way.
foreach($values as $value){
mysqli_stmt_bind_param($stmt, 's', $value);
mysqli_stmt_execute($stmt);
}
If you got a multidimensional array, you can do something like this:
$values = [
['name' => 'John Doe', 'email' => 'john@example.com']
['name' => 'Sally', 'email' => 'sally@example.com']
['name' => 'Bella', 'email' => 'bella@example.com']
];
Now you can loop through this array but remember, don't forget to store the values in specific variables since a variable reference is required while binding params.
foreach($values as $value){
$name = $value['name'];
$email = $value['email'];
mysqli_stmt_bind_param($stmt, 'ss', $name, $email);
mysqli_stmt_execute($stmt);
}
There are other ways as well. I tried to keep it simple just to give you an idea.
AssadUllahCh thanks but it was silly of me as i forgot to turn on auto increment
Well, It's not mandatory to use auto-increment for ids. Following are the few more options for you.
Set the data type of your ID filed to varchar:
1 - Use PHP time() function to generate the value of user id.
2 - Use PHP random_int() function to generate the value of user id.
3 - Use PHP random_bytes() function to generate the value of user id.
4 - Use PHP openssl_random_pseudo_bytes() function to generate the value of user id.
Don't forget to check if the ID already exists in the database to avoid duplication.
Thanks... I got a strange problem with one of my tables. For some reason, it is not inserting into the table.... Here are my variables and sql query with prepared statement.. Sorry for the long code..
$subscriptionplan = null;
$subscriptionplan2 = null;
$subscriptionplan3 = null;
$subscriptionplandate = null;
$subscriptionplandate2 = null;
$subscriptionplandate3 = null;
$feesmonthly = 100;
$feesmonthly2 = null;
$feesmonthly3 = null;
$feesyearly = null;
$feesyearly2 = null;
$feesyearly3 = null;
$paid = 0;
$paid2 = null;
$paid3 = null;
$expirydate = null;
$expirydate2 = null;
$expirydate3 = null;
$paidbydate = null;
$paidbydate2 = null;
$paidbydate3 = null;
$emailreminder = 0;
$emailreminder2 = null;
$emailreminder3 = null;
$overdue = 0;
$overdue2 = null;
$overdue3 = null;
$token = 'qqewreqreqwsdfdfdafcbvcQERFGHFGHGFHRETERTDF!@#$%^^()';
$token = str_shuffle($token);
$token = substr($token, 0, 10);
$token2 = null;
$token3 = null;
$activate = 0;
$activate2 = null;
$activate3 = null;
$level1promo_activate = null;
$level2promo_activate = null;
$level3promo_activate = null;
$sql ="INSERT INTO memberships (user_uid, user_email, subscriptionplan, subscriptionplan2, subscriptionplan3, subscriptionplandate, subscriptionplandate2, subscriptionplandate3, feesmonthly, feesmonthly2, feesmonthly3, feesyearly,feesyearly2, feesyearly3, paid, paid2, paid3, expirydate, expirydate2, expirydate3, paidbydate, paidbydate2, paidbydate3, emailreminder, emailreminder2, emailreminder3, overdue, overdue2, overdue3, token, token2, token3, activate, activate2, activate3, level1promo_activate, level2promo_activate, level3promo_activate) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "ssssssssiiiiiiiiissssssiiiiiisssiiiiii", $uid, $email, $subscriptionplan, $subscriptionplan2, $subscriptionplan3, $subscriptionplandate, $subscriptionplandate2, $subscriptionplandate3, $feesmonthly, $feesmonthly2, $feesmonthly3, $feesyearly, $feesyearly2, $feesyearly3, $paid, $paid2, $paid3, $expirydate, $expirydate2, $expirydate3, $paidbydate, $paidbydate2, $paidbydate3, $emailreminder, $emailreminder2, $emailreminder3, $overdue, $overdue2, $overdue3, $token, $token2, $token3, $activate, $activate2, $activate3, $level1promo_activate, $level2promo_activate, $level3promo_activate);
mysqli_stmt_execute($stmt);
}
Tryout this query in PHPMyAdmin SQL editor and if it still does not work, You can generate a query using update button located underneath SQL query editor. Use that query and there won't be any issues.
I am trying to resize my picture profile but for some reason, it will only work if I add a width and height here..
echo "";
if ($rowImg['status'] == 0) {
echo "";
} else {
echo "";
}
but when it doesn't work in my CSS code...
if ($rowImg['status'] == 0) {
echo "";
} else {
echo "";
}
.profile_picture {
width: 100px;
height: 50px;
}
It's better to assign a class to modify the styles dynamically. If you think some specific style is not getting applied, just increase it's priority by appending !important right after your desired property.
For example:
.profile_picture {
width: 100px !important;
height: 50px !important;
}
This will apply this width and height no matter what.
I tried to add the !important but it is still showing as.. I can't paste it here... do you have an email so that I can send the picture to you? Can you add padding to move the pictures around?
I tried that but not sure why it is not working... Do you have an email address so that I can show you how it looks like on my browser? Also, are you familiar with font awesome? It has a class such as "fas far-star", would I need to do something like
. fa far-start {}
the class name is as follows:
he did something like $result=mysql_query
if $result && $result 2.... Is he checking to see if the query works?
mysql extension has been deprecated. Why don't you take a look at php.net
Why do you have to use bind param? Is this only used if you don't select all variables? when I selected all of my variables by doing *, I don't have to bind them...
Binding result variables only makes sense if you are selecting the specific columns. If you want to select the whole table, you don't need to bind result.
Take this example:
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)){
// deal with results here...
}
What is the dfifference between mysqli_stmt_fetch and mysqli_fetch_assoc? I have been using the later one..
mysqli_stmt_fetch - Fetch results from a prepared statement into the bound variables
mysqli_fetch_assoc - Fetch a result row as an associative array
Are you familiar with CSS and the wrapper? I have included more unordered lists and it seems to be affecting my wrapper but if I remove the wrapper from the CSS, then it does work.... What is wrapper for?
Also, I have been using mysqli_fetch_assoc all along and I don't think my sql queries is an array... is it just storing it as an array?
wrapper? I believe you are talking about the class name or id name if I get it right. Class names allow you to apply same styles on one or more elements whereas the id should be unique.
For example: You got a job in police and you will be given the same uniform as your colleagues. This is where the class name comes into play.
Unlike the class, more than one element cannot have the same id.
// this is an error which browser won't show you but HTML validator can since the same it is assigned to both of the div tags.
// this is correct since both div tags have same class names and now you can apply same styles to more than one elements with just a common css code snippet.
In your case, you want to apply different styles to different elements but you are giving them the same selector name "wrapper" and by the way "wrapper" is just a name which you assigned to it. It could be anything. it's not mandatory to use "wrapper".
Rule of thumb is to give your elements readable class names and id names which makes some sense. For example, the name 'container' or 'wrapper' gives you the idea the element is containing other element(s).
Thanks
This is the first time that I have come across a < sign in sql query. What does the following query mean? because most of the time, I have only used = sign...:
$sql = "SELECT * FROM users WHERE admin < ".$row['admin']."+1;"; mean?
It's a Less than operator same as the one you use in PHP or other programming languages.
AssadUllahCh but how would I interpret that? What is it selecting?
Merv its just a comparison operator which is used to check whether some certain number is less than some threshold.
Say you wanted to select users age less than 18.
SELECT * FROM users WHERE age
I am trying to do this this function and it seems to be working only if I get rid of my background color of grey... I tried to change color but no matter which color I pick, it doesn't seem to help.. If I get rid fdof the header.php, then it does work.. I think the problem is in my css.. I will also include my css coding...
I managed to get it to work but it is only working in IE and not chrome... I don't know why that my CSS is not working well in chrome.....
I managed to get it to work but the strange thing is that some of my CSS does not work in chrome but is workinng IE. I wonder if there might be a problem with some free web hosting as well with css
You need to look into normalize.css and reset css
Thank you a lot
You are welcome mate.
I also have a feeling that this is incorrect:
$sql2 = "SELECT * FROM topics WHERE category_id= '".$cid."' ORDER BY topic_reply_date DESC";
$stmt = mysqli_stmt_init($conn);
Does not make any sense to embed variable directly in SQL when you are using Prepared Statement.
This is strange.. I got it to work for a short while and then it just stops working....
You must have made a mistake somewhere for sure. Inspect your code line by line.
Warning: You have got a new subscriber.
:) You are very welcome.
I thought that chrome browser should be more reliable than IE but my IE is responding better to the CSS than chrome. I am trying to do a drop down menu but for some reason, my display: block is not working for my nav ul li a {}... I had to use padding-top instead to line in the middle....
For this line of code.. it doesn't work;
My header nav ul li a {} doesn't work.. so I have to add padding-top in nav ul li {}
The codepen link is: codepen.io/mervin-lee/pen/RBWEXP
I got the full code here and just wondering if the following if statements do make sense for me? I pasted the php code in the html part of codepen though:
codepen.io/mervin-lee/pen/LBWYdM
codepen does not support PHP
I am also trying to get this loop to work and I can get it working and to display the id properly if using$row['id'] but can I do it by using $x? as shown here because it doesn't work:
while ($row = mysqli_fetch_assoc($result)) {
for ($x = 1; $x
You lack basics of HTML, CSS and PHP. I would recommend you to work on your basics first. Learn how all the loops work in PHP. What are the arrays. How to manipulate arrays etc.
mysqli_fetch_assoc() this function returns ASSOCIATIVE ARRAY not INDEXED ARRAY. So, you need to use mysqli_fetch_array() instead of it. This function will return a hybrid array containing index numbers and index names as well.
Don't forget to keep debugging your code using print_r() or var_dump() functions.
Inside your while loop, if you do this:
print_r($row);
It will show you the array, it's keys and values as well. This way you will get the idea how you can handle the result.
I am trying to learn about paypal and ipn simulator and was watching another video by passive income but I can' get my listener.php to work... Have you done this before? Here is my code for listener.php
but I have a domain with ihostfull: ihostfull/pianocourse101/index.php but when I put this url in the ipn simulator, it said handshake not verify... I noticed that this domain does not start with http: or www...
Here is the following code for listerner.php
Should the code be working?
I am hoping to get this ipn simulator working so that I can understand how paypal works... thanks!
I am desperately trying to get this to work.....
For some reason, the reset stylesheet from html5 doctor is causing my drop down menu issue.. I have got the following drop down meny and here is the code from code pen....
codepen.io/mervin-lee/pen/oMjVyp
Here is the pencode link.. I hope this is the right one:
codepen.io/mervin-lee/pen/WKQGqZ
I am still confused as how to save the variable
"piano 0011 Lee"
In the whole comment section
Bro do u have crud operation with this query ?
Here you go: ruclips.net/video/k8DIHwBgpnA/видео.html
Thanks
you are welcome