-
Posts
5,449 -
Joined
-
Days Won
174
Everything posted by mac_gyver
-
Need some help filling a form based on user selectection in dropdown..
mac_gyver replied to A JM's topic in PHP Coding Help
your first step will be to code this and get it working without ajax (the core html and server-side code will be needed in either case and will be virtually the same with or w/o ajax) using an onchange event for the select menu that submits the form the select menu is in. then, to add ajax, you will assign an event handler/function to the select menu that when called uses ajax to submit the selected option to the server side code, receives the data back, and populates the form fields. -
at call time, any variables that were forming the calling parameter list have been replaced with their value, so there's no way of knowing the name they had (parameters can be literal values, variables, other functions...) the best you could do would be to use the parameter number for referencing them or you would need to form an array with keys/values, the keys being the name you want to use, and then use that array as a parameter to the constructor. using the array method, you would simply store that array as a class property and use a magic __get method to read any value using it's name.
-
id's, by definition, must each be unique on the page, i.e. you cannot use the same id more than one time on a page. to do what you want, show/hide a group of elements, you can either put the elements inside a containing <div id="adiv"> or give each element the same class name and show/hide them based on the class name.
-
Multiple Table Query, while inside a while, results=table length?
mac_gyver replied to devil614's topic in PHP Coding Help
the other forum where you copy/pasted your code from messed up the formatting. i suggest you post your original code with correct formatting and using this forum's bbcode tags (the edit form's <> button) if you want anyone to look at your code. -
you need to set both settings that i mentioned. they do different things that together cause errors to be reported and displayed. you are also going to need to remove the output buffering statements from your code and forget you ever saw any ob_start/ob_end_... statements unless you are intentionally trying to buffer output. add - ini_set("display_errors", "1"); to your code. and, another btw - you should not be trying to learn php, develop php, or debug php code on a live web hosting server. it wastes a huge amount of time constantly uploading code (and making sure you actually uploaded the correct code and that the upload worked) just to see the result of each change.
-
what would be your current login and main files? btw - i edited my post above while you were writing a reply. when you get to the point of the main.php including the safe.php code, it won't work because of the mix of mysql and mysqli functions and you also still have a mysql_error() statement in your login code that won't work should a query error occur.
-
it's possible that your session_start() is failing and given that you are using a META Refresh to redirect, very likely. when learning php (or anything new in php), or developing or debugging php code, you need to have php's error_reporting set to E_ALL and display_errors set to ON so that php will help you by reporting all the errors it detects. you should set these in your php.ini so that even parse errors in your main file are reported and so that you don't need to remember to put the settings in for development and remove them when putting code onto a live server. you can put the settings into your main file, but they won't help with parse errors in that file and they must go before all your other php statements so that errors that are occurring in any of your other php statements will be reported. btw - you cannot mix both mysql (no i) and mysqli statements on the same database connection. you must pick one set of functions and stick to it throughout all your code and since the mysql (no i) functions are depreciated, you should use only the mysqli functions so that you don't need to rewrite your code in the near future when the mysql (no i) functions are removed.
-
inside of a double-quoted string, php variables, in this case your $new_con mysqli instance, are replaced with their content and an instance of mysqli has no meaning inside of a string and cannot be converted to a string. the only part you should be building in the $mysqli variable is the actual (my)sql query statement. the code that is going to run that query would be separate and would use the resulting query statement that would be in the $mysqli variable - // build the (my)sql query statement $mysqli = "CREATE TABLE IF NOT EXISTS $main_table ....."; // run the query mysqli_query($new_con,$mysqli);
-
the hashing method you used in the registration phase on the password must be used in the login so that values can be compared, i.e. apples to apples or hash value to hash value.
-
the short opening tag is not always enabled, resulting in code that is not portable between different php configurations. there should be little to no cost in converting code to use full opening php tags. it would take about two minutes using a couple of search/replaces with a editor that can operate on all files within a project. edit: and i just noticed you posted this in the html help forum. moving to the php help forum....
-
can't get username from database and display it
mac_gyver replied to ArshSingh's topic in PHP Coding Help
you have to test for the existence of the folder and create it if it doesn't exist before you can move a file into it. -
posting your 1500+ line php.ini is pointless because a) no one's going to look at the mess it made of the post, and b) php might not even be using that php.ini file. what sort of errors or symptoms are you getting the lead you to believe mysqli isn't working?
-
Access Denied For User 'Root' @ 'IPADDRESS' (using password:NO)
mac_gyver replied to NickD's topic in Third Party Scripts
all the code you have posted is using the same library of functions, mysql (no i), so this problem is not due to mixing one type of connection with a different type of query calls. just because you have the mysqli extension enabled, you must use the mysqli_ functions in your code to make use of it. best guess is your include file isn't being included and you don't have a database connection at the point where the mysql_real_escape_string function is being used and the error is actually coming at that point (php attempts to make a mysql connection at any mysql statement if there isn't already a connection, but this usually fails since the default user/password that php uses for this is usually not set.) start by making sure that php's error_reporting is set to E_ALL and display_errors is set to ON. you should actually have these set in your php.ini, but you can set them in your code, immediately after the first <?php tag. -
Access Denied For User 'Root' @ 'IPADDRESS' (using password:NO)
mac_gyver replied to NickD's topic in Third Party Scripts
it's likely that the complete error message (less any server specific account/path info in it) would provide additional information as to the problem or knowing at what point in your code that error is being produced. best guess, either the path to your included file is different for this particular code and the database connection wasn't attempted or you are mixing using mysql functions in your code but your database connection is actually a mysqli connection, and your mysql_real_escape_string/mysql_query functions are actually trying to create a mysql connection using the default/empty database connection credentials. to help pin down the problem, your generic die(mysql_error()) should actually include a text string identifying what was occurring when the code failed. was the code trying to make a database connection, was it trying to select a database, was it trying to run a query (and which query, i.e. echo the sql query being ran as well.) -
the database connection username/password is only known to your application code and the database and is only used to authenticate the connection between your application code and the database. the database connection username/password has nothing to do with the visitor's username/passwords that your application stores in a database table and uses to authenticate the visitor.
-
the Visual Server has nothing to do with apache/php. you need to slow way down and start with what operating system you are going to be doing this on and how many concurrent users you are going to support (the non-server and non-pro versions of MS operating systems limit the number of concurrent tcp/ip connections.). if you are using higher than winXP, you should be using the latest of everything, which would be the VC11 versions of apache and php along with the VC11 version of the Visual C++ Redistributable package (which as mentioned in the reply in your other thread, is free.)
-
code using http_build_query would look like this - // inside your loop that is producing the output grid of products - $ref['expand'] = $wherever_you_are_getting_these_values_from_now; // e.g. Yellow@Tint@(N-P) $ref['first'] = $wherever_you_are_getting_these_values_from_now; // e.g. 10@Hearts@_@Arrows $ref['second'] = $wherever_you_are_getting_these_values_from_now; // e.g. Yellow@Tint@(N-P) $ref['level'] = $wherever_you_are_getting_these_values_from_now; // e.g. 3 $link_text = $wherever_you_are_getting_these_values_from_now; // the text for the link, e.g. Yellow Tint (N-P) $qstring = http_build_query($ref, '', '&'); echo "<a class='topseltxt' href='gem.php5?$qstring'>$link_text</a>";
-
yes, those settings in your main code, provided some of your code after that point isn't further altering those settings, will show all runtime errors and fatal parse errors in any files being included by your main code. edit: i still see a lot of non-urlencded @, (, ), -, and possibly spaces in links. the values that go into the links for the level= www, expand= xxx, first= yyy, second= zzz, must be urlencoded. i recommend that you use one of php's functions like http_build_query to make the query string. you would have an array of the values, then just call http_build_query (it takes the & or & separator you supply and does the urlencoded of the values for you.)
-
if you post just an example, showing some sample database rows, what your input is (what $earchForNumber comes from and is it going to be one value at a time or are you actually doing this for a whole month of days or what), and what result you are trying to produce from that input and the data, it will be much easier to help you. also, for anything like an event/booking schedule, you would need the year stored as part of the date to avoid ambiguous results at the end/start of years and once you have data for more than one year.
- 8 replies
-
- 2d arraysubarray
- key
-
(and 2 more)
Tagged with: