-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
Show us how you are doing that. And where is the png file located? Are you providing the loc/path
-
You're not using the db connection in your query call. Do you have error checking turned on to see other errors? And you should really be learning how to use a prepared query instead of just pushing un-validated data into your db
-
cents? As in "dollars and cents"? Added to a datetime value? Why ever would one want to do that?
-
You do realize that this post is over 4 years old?
-
The use of a while in your last is not wise. You should use the foreach on $this->data. Or get the count value ahead of the loop and then use a for using $i=0;$i<$cnt;$i++ and then use $i as the index into your array of query results. OR stick with the foreach that you already showed.
-
Where in the code does it cause "$this->data" to change? Looks you just keep loading up the same data over and over. And - shouldn't you have a set of square brackets on $post_data when you assign a new array to it? If you WERE doing a loop on some new data each time thru your current code is only going to save one set of data that being the last one.
-
if check with multiple logical operators failing with error
ginerjm replied to raphael75's topic in PHP Coding Help
It's still an odd looking way to write a simple If. Makes one have to puzzle over the code in the future. Why not write a 'normal' if statement to make it easier for the next guy who has to work with your code? -
Actually change this line to read: User_perms would be the table that connects a Users userid to the User_perms userid to retrieve a permcode and you would add the perms table to the query (thus 3 tables) to get the literal value of the user's permissions. May seem silly but a good practice is to avoid using literal values in tables in case they need to be modified down the road.
-
You have the design idea. And I gave you a query to use. I would also assign a code to the perms so that you each record doesn't have a 'literal' in it. Users would be user info with a userid as key Perms would be the perm names and their permcode with permid as key User_perms would be the table that connects an userid to a permid to retrieve a permcode and you would add the perms table to the query (thus 3 tables)
-
You have a possibly poor db design. It appears that you have designed the Perms table to hold 4 or more permissions on a single record. The perms s/b all on individual records keyed by id and your query will join all the matching records using the following query $q = "select u.id, u.username, p.perm from users u, perms p where u.Id = p.Id" Your perms table should be simply "id, perm". The query will return a record for every permission that the id is assigned.
-
if check with multiple logical operators failing with error
ginerjm replied to raphael75's topic in PHP Coding Help
I am unfamiliar with the statements you are writing. I"m guessing you want to know the value of the set of 4 conditions. Why don't you write an If statement to do that? And what do you want to see after you perform this test? You are only showing a result wrapped in brackets. When I run this it works just fine but it looks rather silly. Here is how I would have done this: echo "Test #1 gives "; $a = 76; $b = true; $c = 0; $d = 500; if(($a > 0) && ($b == false) && ($c == 0) && ($d > 0)) echo "The result is 'true'<br>"; else echo "The result is 'false'<br>"; echo "Test #2 gives "; $a = 76; $b = false; $c = 0; $d = 500; if(($a > 0) && ($b == false) && ($c == 0) && ($d > 0)) echo "The result is 'true'<br>"; else echo "The result is 'false'<br>"; exit(); -
<?php if (login_check($mysqli) == true) : ?> Cannot load
ginerjm replied to xhulio's topic in PHP Coding Help
Seems to me that you should be querying for the user id and the password, not the email. -
Does this work at all, ie, does the form show up? Curious to know which line is giving you the error? IE, line 345? If it is the first appearance of multi-query the message is saying that something is null. That is most likely the $mysqli variable. PS - I seem to recall that multiple query statements in places where one can do that kind of thing need a semi to separate the multiple statements. You are not doing that here.
-
Php set a Checkbox as checked at start from page
ginerjm replied to Foracc's topic in PHP Coding Help
You can send the html code from your php code and then use JS to check it from a trigger on your web page if you wish. Need to set an id on the input tag to do that. document.getElementById('chkbox').checked = true; -
include_once 'psl-config.php'; function sec_session_start() { $session_name = 'sec_session_id'; // Set a custom session name $secure = SECURE; // This stops JavaScript being able to access the session id. $httponly = true; // Forces sessions to only use cookies. if (ini_set('session.use_only_cookies', 1) === FALSE) { header("Location: ../error.php?err=Could not initiate a safe session (ini_set)"); exit(); } // Gets current cookies params. $cookieParams = session_get_cookie_params(); session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly); // Sets the session name to the one set above. session_name($session_name); session_start(); // Start the PHP session session_regenerate_id(); // regenerated the session, delete the old one. } Ok - you seem to be retrieving the pre-set cookie param from the ini file settings and re-setting them to the same values. Do I not understand what the manual is telling me? After that you set your own custom name for your session and then starting it up. I don't understand what your topic title is saying so what is the problem here?
-
Php set a Checkbox as checked at start from page
ginerjm replied to Foracc's topic in PHP Coding Help
<input type="checkbox" name="Checkbox" checked value="true">Checkbox</input> All you need is 'checked' to set it. Plus it is good to set a value such as 'true' or something indicative of which checkbox has been selected. PS - in php I find it easier to use all lowercase names to avoid mis-types and wondering why something is not being recognized. Remember - if a checkbox is not checked, then $_POST['Checkbox'] will not show up. -
Little function like If $variable == 0 then echo "--"
ginerjm replied to paulmagm's topic in PHP Coding Help
One reason that I RARELY use them at all. After 40 years I prefer to just write the old I/T/E. -
Little function like If $variable == 0 then echo "--"
ginerjm replied to paulmagm's topic in PHP Coding Help
Here is little script that demos how this could be written and how you wrote it. // set the starting value $max_supply = 0; echo "Starting with max_supply of $max_supply<br>"; // show the formatted value $fmt_val = number_format($max_supply, 0, '.', '.'); echo "The formatted value is: $fmt_val<br>"; // now test the final value echo "The test of the formatted value gives us: "; if($fmt_val == 0) echo "--"; else echo $fmt_val; echo "<br><br>"; // now run the OP's original lines of code echo "OP code results. (written on separate lines as it s/b.)<br>"; echo "Output of the formatted max_supply value: "; echo number_format($max_supply, 0, '.', '.'); echo "<br>"; echo "Output of the test of max_supply for a value of zero: "; if($max_supply == 0) echo "--"; exit(); And here is the output: Starting with max_supply of 0 The formatted value is: 0 The test of the formatted value gives us: -- OP code results. (written on separate lines as it s/b.) Output of the formatted max_supply value: 0 Output of the test of max_supply for a value of zero: -- I"ll let you decide what needs changing if you only want to see ONE value. The problem with your lines of code was that you didn't realize that number_format doesn't alter the starting value - you were seeing the output done by number_format but in the next line you were testing the original value. -
Little function like If $variable == 0 then echo "--"
ginerjm replied to paulmagm's topic in PHP Coding Help
Actually - if you had saved the formatted number before doing the entire echo statements you probably would not be seeing the -- since the formatted resulted would be a string and therefore <> to a numeric zero. But you didn't. -
Little function like If $variable == 0 then echo "--"
ginerjm replied to paulmagm's topic in PHP Coding Help
You are echoing the formatted number and then asking for the -- to be echoed if is a 0. What did you expect? -
Little function like If $variable == 0 then echo "--"
ginerjm replied to paulmagm's topic in PHP Coding Help
1 - do not write code like you just presented to us. Use separate lines for each statement. You won't regret it. 2 - you should not have to enter and exit php mode for a couple lines of php code. Unless you are poorly structuring your script. So - break that habit. 3 - You are asking us to give you an explanation yet we don't know WTH your code is doing to the $max_supply variable. Are you kidding? -
get windows username onto a live server using php,or ajax
ginerjm replied to Sidhu's topic in PHP Coding Help
And what do you consider a 'windows username' to be?