-
Posts
5,449 -
Joined
-
Days Won
174
Everything posted by mac_gyver
-
it would probably help if you posted the undefined error you got. what are the column names in your products table? btw - you should never run queries inside of loops. it's likely that everything you are trying to get your code to do can be done in one single query or at most one query and a small amount of php code (for the combined average.) you can calculate the average of data using the mysql AVG() function in the query.
-
the way to fix errors is to find out what is causing them and fix the problem. setting $_GET['register']=''; will make the error message go away, but it will also prevent your registration script from working. for your undefined index in $_GET['register'], the correct way of handling a variable that is optional is to use isset() - $register = isset($_GET['register']) ? (int)$_GET['register'] : false; as to your login not working, what exactly happens? what page, result, or output message do you get?
-
since your form field is an array, and you apparently have 4 similar select menus, you must use array notation/functions to access the elements of the array. you can either use your for($i=0;$i<4;$i++){ loop index $i variable - $points=$_POST['points'][$i]; or just use a foreach loop foreach($_POST['points'] as $points){ ... }
-
what debugging have you done to pin down where the problem is at? do you have php's error_reporting set to E_ALL and display_errors set to ON so that php will help you by reporting and displaying the errors it detects?
-
the query you have posted and the error message you have posted don't match. best guess is your actual query has two where keywords in it. to get programming help, you must post accurate information.
-
no you didn't, because it's not the browser that's including the file, it's php. the source that trq referred to is the 'view source' in your browser. the resulting html/css/javascrpt that's output to the browser must be correct.
-
in your form field, name="points[]" is an array. it won't be numeric.
-
your session variable $_SESSION['userid'] is the only thing that is 'fixed' for a user. a user could have his group membership changed (or even change his display name) on the fly. so, for completely general purpose, fool proof code, you should only identify who a user is through a session variable and query on each page request to find out anything else about them.
-
did you read the last comment in your '$Post Multiple Variable from a Single <option>' thread?
-
the fopen() statement doesn't even have anything to do with ftp, assuming you are trying to open the .csv file on the server where this code is running. based on your last posted code, the error you are getting means what it says, either the file or directory you are using in the fopen() statement doesn't exist. you are aware that the leading / you have on the file system path refers to the root of the current hard disk?
-
How to combine these two outputs as one
mac_gyver replied to chauhanRohit's topic in PHP Coding Help
you have now switched your code to use a query that's join'ing every row from the author table with every row from the book table. at this point, i don't think we can help you. all you are doing in this thread and in the thread in the other help site is to randomly change things without any reason behind it. you were also told in the other help site that if there's no relationship between the two pieces of output, that you need to use two queries. -
Moderate user submitted content script ?
mac_gyver replied to kutchbhi's topic in Third Party Scripts
see this sticky post - http://forums.phpfreaks.com/topic/195880-this-board-is-not-a-script-repository/ -
Warning: getimagesize(): Filename cannot be empty.
mac_gyver replied to FmanTheCoder's topic in PHP Coding Help
did you read the error? it is fairly self explanatory, $_FILES['images']['tmp_name'] is empty. is your code checking if the upload worked before trying to use any of the uploaded file information? -
did you look at your query statement? you have typed a space in it after the $DNF[$i] variable.
-
the html layout of your web page shouldn't be stored in the database, only the content that goes on the web page.
-
when you use php to include a file, it essentially replaces the include() statement with the content of the file being included. it doesn't matter where the file being included is stored at, it could be twenty folders deep in your site or even below/outside your document root folder, any links in the resulting web page are relative to resulting web page, they aren't relative to where the included file is stored at.
-
http://us1.php.net/json_decode
-
How to combine these two outputs as one
mac_gyver replied to chauhanRohit's topic in PHP Coding Help
programming requires that you define what data you have as inputs to your code and what output you want to produce from that data. all you have stated is you want to combine two outputs. you haven't shown or stated what output you want or what is wrong with the output your code currently produces. if you post some example data from your two tables, 2 or 3 rows each would be enough, and show what exact output you want to produce for that example data, someone can probably help you. -
your form is using method='post', so $_GET['shift'] will never exist.
-
the path shown in the error message doesn't match what you are showing in your code. the posted fopen() line of code is also invalid, containing a syntax error and is also missing a 2nd parameter. if you want programming help, you must show accurate, unadulterated information.
-
that's a sign you need to store the content in a database and dynamically output it using ONE page. by producing a large number of php files that only vary in the content they contain, you are just making a lot of make-work for yourself producing and managing the files. the the computer do this work for you. as to your problem. the php include statement essentially replaces the include() statement with the content of the file being included. it doesn't matter where the file being included is stored at, it could be twenty folders deep in your site or even below/outside your document root folder, any links in the resulting web page are relative to the main file.
-
jQuery datepicker end of month day departure +1
mac_gyver replied to erme's topic in Javascript Help
you need use getDate() to get the current day from the first date object, then add the number of days (1) to that value, then use setDate() to set the second date object to the modified value. see this link - http://www.ehow.com/how_6810273_add-days-date-javascript.html -
the answer to your question is - you retrieve the selected data from your database table and output it in value=' ... ' attributes for each form field. when you select a name, you would also need to provide a way of submitting the name select/option value. however, your code is a hodge-podge mess of mysql_/mysqli_ database functions, nested forms, form processing logic mixed in with the code producing your html document, unconditionally running form processing logic, no validation or escaping of data being put into queries... the mysql_ database functions are depreciated and should not be used. since you ARE using mysqli_ functions, use those everywhere. nested forms are invalid markup. if your form(s) do work, it's only because they have the same action='' attribute. a majority of your php code that determines what to do on the page, process the form data, and runs database queries to retrieve data should be grouped together and come first on the page. this is referred to a the 'business logic.' the code producing the actual html document (and any css/javascript) should be grouped together and come last on the page. this is referred to as the 'presentation logic.' if you search the forum for the term 'business logic' you will find examples showing this organization principle. your form processing logic must both test is a form has been submitted at all and it must validate the submitted data before using it. lastly, string data being put into sql query statements must be escaped and numerical data needs to be validated/cast as the appropriate numerical data type (or you need to use prepared queries.)
-
the first form isn't actually a url/link, it's the html markup you would output on a web page for a url. the browser renders the & as an & and when you click on that, it should submit correctly as the second version of the link you posted. the reason for the errors are because your query is failing, due to an error, and you are not testing if the query actually ran before trying to use the result from the query, most likely because $_GET['cat'] is being used in the query as a numerical value, but it doesn't exist at all, let alone being a valid integer representing a cat value, for the first form. you ALWAYS need to validate external data before using it. if your code requires a $_GET['cat'] value and one hasn't been submitted, your code should either use a default value or prevent the remainder of the code that is dependent on having a valid $_GET['cat'] from even running. you should also ALWAYS test if your queries run without any errors before trying to use the data you expect from your queries.
-
this thread seems to be a variation of the same code and query error in your previous thread. i recommend you revisit that thread and read my reply in it concerning the sql syntax error you are getting.