Re: [PHP-DB] html input element rendering html entities
Govinda wrote: I've got a form that loads and saves product data to mysql. In some fields like the heading and subhead we use special characters like Omega, Registered Trademark, and Ampersand. When putting the data in I will encode them as Omega;, etc. Once saved, all is good, everything goes ok and will display correctly in the user interface. However, if I go back to edit that product, in the html input element, it will actually display the character rather than the entity code (although when checking the source, the html entity is coded correctly). Then when it is saved, it saves as the illegal character I am newbie here, but isn't it that you just need to save at this ^^ point the same way that you saved the data in the first place? If it worked the first time, why not now? and will serve up a few funky characters in the user interface and in the database. I have the code stripping out tags and I tried to use the mysql_real_escape_string to no avail. Anyone have experience with this kind of thing? PHP Version 5.1.6*MySQL 5.0.19* That's the thing, it is being saved the same way, it's that when the page loads the data the input element automatically changes the display to the special character, and when it saves, it saves as that character. then you just need to encode that form input value coming from the db back into the amp; entity, etc. AS YOU WRITE IT into the form input value HTML. I suspect there must be a built-in function just for this purpose. Someone can probably say what that is without looking (unlike me). But I did just look and how about this: htmlspecialchars ? -G Try this: http://us2.php.net/manual/en/function.htmlentities.php __ Information from ESET NOD32 Antivirus, version of virus signature database 4250 (20090716) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] displaying info in a form
I have come across this before. Make sure you put around the value field and then single quotes around the variable, ie. tdinput type=text value=?php echo '$tracking_num' ? /td tdinput type=text value=?php echo '$id' ? (NOTE: if this is an int value, you do not need to use the single quotes around $id) /td tdinput type=text value=?php echo '$name' ? /td tdinput type=text value=?php echo '$user' ? /td /tr tdinput type=text name=comment value=?php echo '$comment' ? HTH MB Natividad Castro [EMAIL PROTECTED] said: Hi to all, I'm trying to display data in a form, but for some reason I can display the entire value of every field that has more than two words in the text box. For example, if I want to display the name CASTRO TRUCKING, the text field only display the first word CASTRO. I tried to use the trim() function, but it didn't work. Any idea? Thanks in advanced. Nato here is the code html body ?php include ./connection.php; //include ./common_db.inc; //$link_id = db_connect('test_bia'); $result = mysql_query(SELECT * FROM test LIMIT 0, 1); //while($query_data = mysql_fetch_array($result)) { echoform; while($query_data = mysql_fetch_array($result)){ $tracking_num = $query_data[0]; $id = $query_data[1]; $name = $query_data[2]; $user = $query_data[3]; $comment = $query_data[4]; } ? table border=1 form name=test action=test.php method=post tr tdinput type=text value=?php echo $tracking_num ? /td tdinput type=text value=?php echo $id ? /td tdinput type=text value=?php echo $name ? /td tdinput type=text value=?php echo $user ? /td /tr tdinput type=text name=comment value=?php echo $comment ? tr tdbrbr input type=submit value=Send /td/tr /form /td/tr/table /body /html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Array HELL!!!!
Try putting the hidden element statement down inside the while loop in he second page, but change it to INPUT TYPE=\hidden\ NAME=\id[]\ VALUE=\$id\ and add $id=$row['id']; before it. I will show below where it should go. HTH MB jas [EMAIL PROTECTED] said: I have made the changes you suggested which if you ask me have been the most informative answers I have recieved thus far. I did run into a slight snag on line 21 which is this on my confirmation page INPUT TYPE=\hidden\ NAME=\id[]\ VALUE=\$id[]\ and the parse error is as follows... Parse error: parse error, expecting `STRING' or `NUM_STRING' or `'$'' in /php/rem_conf_t.php3 on line 21 Wouldn't I need to adjust the value=\$id[]\ to something like value=\.$id[].\ because we passed an array not a string? Not sure. Thanks again. You are sincerely helping me understand this whole php bit. =) Jas [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Ok, you have almost got it. I have made little remarks further down in your code which should just about do it for you. jas [EMAIL PROTECTED] said: I don't know what it is but I am having a hell of a time trying to get some results of a query setup into an array or variable (too much of a newbie to know which) that can be passed to a confirmation page before deleting the record from a table. I have given up working on this but for those of you that want to finish it here is the code and the table structure... [Table Structure] id int(30) DEFAULT '0' NOT NULL auto_increment, car_type varchar(30), car_model varchar(30), car_year varchar(15), car_price varchar(15), car_vin varchar(25), dlr_num varchar(25), PRIMARY KEY (id) [Page 1 - Queries DB table for records] ?php require '../path/to/db.php'; $result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not execute query, please try again later); echo table border=\0\ class=\table-body\ width=\100%\form name=\rem_inv\ method=\post\ action=\rem_conf.php3\ trtd align=\center\ colspan=\3\font size=\4\BCurrent Inventory/B/fonthr color=\33\/td/tr; $count = -1; $count should start at 0 and then increment at the bottom of the while loop while ($myrow = mysql_fetch_array($result)) { $id = $row[id]; $row should be $myrow since that is what it is called above (or change $myrow above to $row) $car_type = $row[car_type]; $car_model = $row[car_model]; $car_year = $row[car_year]; $car_price = $row[car_price]; $car_vin = $row[car_vin]; $count ++; $count ++; should be moved to the bottom of the loop just before it is closed echo trtd width=\30%\BType Of Car: /B/tdtd; printf(mysql_result($result,$count,car_type)); mysql_result is not needed here, you have defined the variable $car_type to be this here as well as the rows below, so replace mysql_result($result, $count, car_type) with just $car_type echo /tdtdinput type=\checkbox\ name=\id[]\ value=\.$myrow[id].\remove/td/tr\n; replace $myrow[id] with $id since it is already defined above when id[] is passed to page 2, it will contain an array of the id numbers that got checked echo trtd width=\30%\BModel Of Car: /B/tdtd; printf(mysql_result($result,$count,car_model)); same as above, replace mysql_result($result,$count,car_model) with $car_model echo /td/tr\n; echo trtd width=\30%\BYear Of Car: /B/tdtd; printf(mysql_result($result,$count,car_year)); same as above replace with $car_year echo /td/tr\n; echo trtd width=\30%\BPrice Of Car: /B/tdtd$; printf(mysql_result($result,$count,car_price)); same as above replace with $care_price echo /td/tr\n; echo trtd width=\30%\BVIN Of Car: /B/tdtd; printf(mysql_result($result,$count,car_vin)); same as above replace with $car_vin echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n; $count ++; should go here } echo trtdinput type=\submit\ name=\delete\ value=\delete\/td/tr/form/table; ? [Page 2 - Takes records and confirms which ones to be deleted] ?php print( table border=\0\ class=\table-body\ width=\100%\ form name=\rem_inv\ method=\post\ action=\done2.php3\ send id[] array passed from previous page to the next page: INPUT TYPE=\hidden\ NAME=\id[]\ VALUE=\$id[]\ If you are planning on deleting multiple items at a time, you won't need the following hidden elements at all, just make a database call at this point using the id[] array passed to this page from the first page. The only value it needs for the 3rd page is the id value since that is what it uses to determine what to delete. Here is an example of the database call to make: $i=0; while ($id[$i]) { $result = @mysql_query(SELECT * FROM cur_inv where id=$id[$i],$dbh) or die (Could not execute query, please try again later);
Re: [PHP-DB] Passing contents of array on as variables...
Let's see what your code looks like now and where it is returning the word array. That might help determine where the problem lies now. MB jas [EMAIL PROTECTED] said: Ok to this point I have been able to query a database table, display the results in tables and within a form. As of yet I have been able to insert the contents of the db query into an array for further processing. However, when I try to pass the contents of that array on to another page to delete selected records from the db it only displays the word array. Not quite sure where I need to go from here... Any insight would be a great help. Thanks in advance, Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Passing contents of array on as variables...
You didn't add the value part of the hidden element, ie. INPUT TYPE=\hidden\ NAME=\car_type\ value=\$myrow[car_type]\ You were naming the field as an array with no value. if you want to pass this as an array of values, you would need to use: INPUT TYPE=\hidden\ NAME=\car_type[]\ value=\$myrow[car_type]\ Give that a try and see if it works. HTH MB jas [EMAIL PROTECTED] said: As of right now if you run the php script and view source on the page you can see that it does place the content of db table into array... ex. BCurrent Inventory/B/fonthr color=33/td/tr INPUT TYPE=hidden NAME=car_type[Ford] INPUT TYPE=hidden NAME=car_model[Ranger] INPUT TYPE=hidden NAME=car_year[1999] INPUT TYPE=hidden NAME=car_price[5600] INPUT TYPE=hidden NAME=car_vin[no vin] trtd width=30%BType Of Car: /B/tdtdFord/tdtdinput type=checkbox name=id[1]remove/td/tr but on the following page (after selecting items to delete) it just displays the word array for each field (i.e. car_type etc.) Jas [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Oops... yeah its a monday. Bjorn, I reverted back to my original code because I was getting confused... Here is page one... ?php // Database connection paramaters require '../path/to/db.php'; // SQL statement to get current inventory $result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not execute query, please try again later); // Creating table to make data look pretty echo table border=\0\ class=\table-body\ width=\100%\form name=\rem_inv\ method=\post\ action=\rem_conf.php3\ trtd align=\center\ colspan=\3\font size=\4\BCurrent Inventory/B/fonthr color=\33\/td/tr; // Start to count number of records in selected table and loop until done $count = -1; while ($myrow = mysql_fetch_array($result)) { $count ++; // Begin placing them into an hidden fields and then array echo INPUT TYPE=\hidden\ NAME=\car_type[.$myrow[car_type].]\ INPUT TYPE=\hidden\ NAME=\car_model[.$myrow[car_model].]\ INPUT TYPE=\hidden\ NAME=\car_year[.$myrow[car_year].]\ INPUT TYPE=\hidden\ NAME=\car_price[.$myrow[car_price].]\ INPUT TYPE=\hidden\ NAME=\car_vin[.$myrow[car_vin].]\ // Place items on separate cells in html table trtd width=\30%\BType Of Car: /B/tdtd; printf(mysql_result($result,$count,car_type)); // Create checkbox so user can delete items if needed echo /tdtdinput type=\checkbox\ name=\id[.$myrow[id].]\remove/td/tr\n; echo trtd width=\30%\BModel Of Car: /B/tdtd; printf(mysql_result($result,$count,car_model)); echo /td/tr\n; echo trtd width=\30%\BYear Of Car: /B/tdtd; printf(mysql_result($result,$count,car_year)); echo /td/tr\n; echo trtd width=\30%\BPrice Of Car: /B/tdtd$; printf(mysql_result($result,$count,car_price)); echo /td/tr\n; echo trtd width=\30%\BVIN Of Car: /B/tdtd; printf(mysql_result($result,$count,car_vin)); echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n; } // End loop and print the infamous delete button echo trtdinput type=\submit\ name=\delete\ value=\delete\/td/tr/form/table; ? Here is page two... ?php print( table border=\0\ class=\table-body\ width=\100%\ form name=\rem_inv\ method=\post\ action=\done2.php3\ INPUT TYPE=\hidden\ NAME=\car_type[.$myrow[car_type].]\ INPUT TYPE=\hidden\ NAME=\car_model[.$myrow[car_model].]\ INPUT TYPE=\hidden\ NAME=\car_year[.$myrow[car_year].]\ INPUT TYPE=\hidden\ NAME=\car_price[.$myrow[car_price].]\ INPUT TYPE=\hidden\ NAME=\car_vin[.$myrow[car_vin].]\ tr td align=\center\ colspan=\3\font size=\4\BConfirm Record Deletion/B/fonthr color=\33\/td /tr tr td width=\30%\BType Of Car: /B/td td$car_type/td // here is where it prints the word array instead of type of car /tr tr td width=\30%\BModel Of Car: /B/td td$car_model/td /tr tr td width=\30%\BYear Of Car: /B/td td$car_year/td /tr tr td width=\30%\BPrice Of Car: /B/td td$car_price/td /tr tr td width=\30%\BVIN Of Car: /B/td td$car_vin/td /tr tr td colspan=\3\hr color=\33\/td /tr tr tdinput type=\submit\ name=\delete\ value=\delete\/td /tr /form /table); ? [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Let's see what your code looks like now and where it is returning the word array. That might help determine where the problem lies now. MB jas [EMAIL PROTECTED] said: Ok to this point I have been able to query a database table, display the results in tables and within a form. As of yet I have been able to insert the contents of the db query into an array for further processing. However, when I try to pass the contents of that array on to another page to delete selected records from the db it only displays the word array. Not quite sure where I need to go from here... Any insight would be
Re: [PHP-DB] Passing contents of array on as variables...
When you call your $car_type in the second page, you need to set a variable starting at 0 and call it as $car_type[0] and loop through all of the values in the array. ie. $i=0; while ($car_type[$i]) { I have added more code below that should help. MB jas [EMAIL PROTECTED] said: Yeah, tried that and it still isnt passing the contents of the array as a varible to the confirmation page for deletion. I am at a loss on this one. [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... You didn't add the value part of the hidden element, ie. INPUT TYPE=\hidden\ NAME=\car_type\ value=\$myrow[car_type]\ You were naming the field as an array with no value. if you want to pass this as an array of values, you would need to use: INPUT TYPE=\hidden\ NAME=\car_type[]\ value=\$myrow[car_type]\ Give that a try and see if it works. HTH MB jas [EMAIL PROTECTED] said: As of right now if you run the php script and view source on the page you can see that it does place the content of db table into array... ex. BCurrent Inventory/B/fonthr color=33/td/tr INPUT TYPE=hidden NAME=car_type[Ford] INPUT TYPE=hidden NAME=car_model[Ranger] INPUT TYPE=hidden NAME=car_year[1999] INPUT TYPE=hidden NAME=car_price[5600] INPUT TYPE=hidden NAME=car_vin[no vin] trtd width=30%BType Of Car: /B/tdtdFord/tdtdinput type=checkbox name=id[1]remove/td/tr but on the following page (after selecting items to delete) it just displays the word array for each field (i.e. car_type etc.) Jas [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Oops... yeah its a monday. Bjorn, I reverted back to my original code because I was getting confused... Here is page one... ?php // Database connection paramaters require '../path/to/db.php'; // SQL statement to get current inventory $result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not execute query, please try again later); // Creating table to make data look pretty echo table border=\0\ class=\table-body\ width=\100%\form name=\rem_inv\ method=\post\ action=\rem_conf.php3\ trtd align=\center\ colspan=\3\font size=\4\BCurrent Inventory/B/fonthr color=\33\/td/tr; // Start to count number of records in selected table and loop until done $count = -1; while ($myrow = mysql_fetch_array($result)) { $count ++; // Begin placing them into an hidden fields and then array echo INPUT TYPE=\hidden\ NAME=\car_type[.$myrow[car_type].]\ INPUT TYPE=\hidden\ NAME=\car_model[.$myrow[car_model].]\ INPUT TYPE=\hidden\ NAME=\car_year[.$myrow[car_year].]\ INPUT TYPE=\hidden\ NAME=\car_price[.$myrow[car_price].]\ INPUT TYPE=\hidden\ NAME=\car_vin[.$myrow[car_vin].]\ // Place items on separate cells in html table trtd width=\30%\BType Of Car: /B/tdtd; printf(mysql_result($result,$count,car_type)); // Create checkbox so user can delete items if needed echo /tdtdinput type=\checkbox\ name=\id[.$myrow[id].]\remove/td/tr\n; echo trtd width=\30%\BModel Of Car: /B/tdtd; printf(mysql_result($result,$count,car_model)); echo /td/tr\n; echo trtd width=\30%\BYear Of Car: /B/tdtd; printf(mysql_result($result,$count,car_year)); echo /td/tr\n; echo trtd width=\30%\BPrice Of Car: /B/tdtd$; printf(mysql_result($result,$count,car_price)); echo /td/tr\n; echo trtd width=\30%\BVIN Of Car: /B/tdtd; printf(mysql_result($result,$count,car_vin)); echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n; } // End loop and print the infamous delete button echo trtdinput type=\submit\ name=\delete\ value=\delete\/td/tr/form/table; ? Here is page two... ?php print( table border=\0\ class=\table-body\ width=\100%\ form name=\rem_inv\ method=\post\ action=\done2.php3\ INPUT TYPE=\hidden\ NAME=\car_type[.$myrow[car_type].]\ INPUT TYPE=\hidden\ NAME=\car_model[.$myrow[car_model].]\ INPUT TYPE=\hidden\ NAME=\car_year[.$myrow[car_year].]\ INPUT TYPE=\hidden\ NAME=\car_price[.$myrow[car_price].]\ INPUT TYPE=\hidden\ NAME=\car_vin[.$myrow[car_vin].]\ tr td align=\center\ colspan=\3\font size=\4\BConfirm Record Deletion/B/fonthr color=\33\/td /tr Here is where above loop code would go and $car_type, $car_model, etc. would be called as $car_type[$i], $car_model[$i], etc. tr td width=\30%\BType Of Car: /B/td td$car_type/td // here is where it prints the word array instead of type of car /tr tr td width=\30%\BModel Of Car: /B/td td$car_model/td /tr tr td width=\30%\BYear Of Car: /B/td td$car_year/td /tr tr td width=\30%\BPrice Of Car: /B/td td$car_price/td /tr tr td width=\30%\BVIN Of Car: /B/td td$car_vin/td /tr
Re: [PHP-DB] Passing contents of array on as variables...
One problem I see is that you are sending all of the values for all of your fields (except the id field) from the first page to the second page, not just the ones that are checked, so even if it was working properly, you would get a list of all items in the table, not just the checked items. You need to send the array of id's (since this is the name for the checkbox) from the first page to the second one (again in the checkbox form element, you did not put a value on it). What your first page is currently doing is pulling all of the information out of the database. Then as soon as you pull each item out, you are putting it into an hidden form element array, ie. $car_type[], $car_model[], etc. regardless of whether the checkbox is checked or not to pass to the next page. You do not know if the checkbox is checked or not until the next page when it looks at the values in the id array. On the second page, you need to look at the id array and then (through a database call) pull the row from the table for each id in the array. HTH MB jas [EMAIL PROTECTED] said: $i=0; while ($car_type[$i],$car_model[$i],$car_year[$i],$car_price[$i],$car_vin[$i]) { $i ++; } Is what I added and this is what is being output to the screen at this point... =0; while () { ++; } now i am still too new to php to understand why it is not putting the contents of the array into my hidden fields like it does on my first page (i can see them when I view source). [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... When you call your $car_type in the second page, you need to set a variable starting at 0 and call it as $car_type[0] and loop through all of the values in the array. ie. $i=0; while ($car_type[$i]) { I have added more code below that should help. MB jas [EMAIL PROTECTED] said: Yeah, tried that and it still isnt passing the contents of the array as a varible to the confirmation page for deletion. I am at a loss on this one. [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... You didn't add the value part of the hidden element, ie. INPUT TYPE=\hidden\ NAME=\car_type\ value=\$myrow[car_type]\ You were naming the field as an array with no value. if you want to pass this as an array of values, you would need to use: INPUT TYPE=\hidden\ NAME=\car_type[]\ value=\$myrow[car_type]\ Give that a try and see if it works. HTH MB jas [EMAIL PROTECTED] said: As of right now if you run the php script and view source on the page you can see that it does place the content of db table into array... ex. BCurrent Inventory/B/fonthr color=33/td/tr INPUT TYPE=hidden NAME=car_type[Ford] INPUT TYPE=hidden NAME=car_model[Ranger] INPUT TYPE=hidden NAME=car_year[1999] INPUT TYPE=hidden NAME=car_price[5600] INPUT TYPE=hidden NAME=car_vin[no vin] trtd width=30%BType Of Car: /B/tdtdFord/tdtdinput type=checkbox name=id[1]remove/td/tr but on the following page (after selecting items to delete) it just displays the word array for each field (i.e. car_type etc.) Jas [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Oops... yeah its a monday. Bjorn, I reverted back to my original code because I was getting confused... Here is page one... ?php // Database connection paramaters require '../path/to/db.php'; // SQL statement to get current inventory $result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not execute query, please try again later); // Creating table to make data look pretty echo table border=\0\ class=\table-body\ width=\100%\form name=\rem_inv\ method=\post\ action=\rem_conf.php3\ trtd align=\center\ colspan=\3\font size=\4\BCurrent Inventory/B/fonthr color=\33\/td/tr; // Start to count number of records in selected table and loop until done $count = -1; while ($myrow = mysql_fetch_array($result)) { $count ++; // Begin placing them into an hidden fields and then array echo INPUT TYPE=\hidden\ NAME=\car_type[.$myrow[car_type].]\ INPUT TYPE=\hidden\ NAME=\car_model[.$myrow[car_model].]\ INPUT TYPE=\hidden\ NAME=\car_year[.$myrow[car_year].]\ INPUT TYPE=\hidden\ NAME=\car_price[.$myrow[car_price].]\ INPUT TYPE=\hidden\ NAME=\car_vin[.$myrow[car_vin].]\ // Place items on separate cells in html table trtd width=\30%\BType Of Car: /B/tdtd; printf(mysql_result($result,$count,car_type)); // Create checkbox so user can delete items if needed echo /tdtdinput type=\checkbox\ name=\id[.$myrow[id].]\remove/td/tr\n; echo trtd width=\30%\BModel Of Car: /B/tdtd; printf(mysql_result($result,$count,car_model));
Re: [PHP-DB] Re: Associating table id...
All you need to do is assign the variable (let's call it $id) the id for that record set from the database. Then pass this variable to the next page for the delete. You may want to search for the mysql_fetch_array function on php.net. This would be used to grab the record set from the database to display it on the first page and then pass the id part of the array to the second page as $id. There are some good examples on the page that comes up when you enter mysql_fetch_array into the 'function list' search on php.net. HTH MB jas [EMAIL PROTECTED] said: I sincerely wish someone could give me some insight as to what I am doing wrong here. I have been scouring php.net for any website that has a good tutorial or article on how to pass the variables from page to page while assigning a variable a whole record set from a database. If anyone has run into the same problem that I am having please give me a shove in the right direction. Thanks in advance, Jas Jas [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Ok I have been working on this function to delete an item from a mysql database and so far I have not had any success. Here is the problem I am having (after alot of headaches), I need to be able to associate a checkbox to a record or a set of records... For example, page 1 queries a database and pulls the results into a table and in that table is a form with a checkbox for each record pulled from said database... code is here... ?php require '../path/to/db.php'; //connection script $result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not execute query, please try again later); echo table border=\0\ class=\table-body\ width=\100%\form name=\rem_inv\ method=\post\ action=\done2.php3\ trtd align=\center\ colspan=\3\font size=\4\BCurrent Inventory/B/fonthr color=\33\/td/tr; $count = -1; while ($myrow = mysql_fetch_row($result)) { $count ++; echo trtd width=\30%\BType Of Car: /B/tdtd; printf(mysql_result($result,$count,car_type)); echo /tdtdinput type=\checkbox\ name=\id\ value=\id\remove/td/tr\n; echo rest of fields in database; } echo trtdinput type=\submit\ name=\delete\ value=\delete\/td/tr/form/table; ? Now what I need to do is to have the checkbox item be associated with all one record set. Table structure is here - | id | car_model | car_type | car_year | car_price | car_vin | dlr_num | - | 0 | ford | bronco| 1997 | 6700 | vin# | dlr # | - etc. etc. From the first page it links to page which queries the db and deletes the selected records... however, I am not able to get the id to be associated with the records in the table... the deletion script is as follows ?php require '../path/to/db.php'; $table_name = cur_inv; $sql = DELETE FROM $table_name WHERE id = '$id'; echo($sql); $result = mysql_query($sql,$dbh) or die(mysql_error()); print(record deleted); ? If anyone has ever run into this please help... I am still fairly new to php and mysql and there is definately something I am missing here and I think its because I need to associate the checkbox with the id and the id field from the database does not seem to be linked to the rest of the record in said fields... Thanks in advance, Jas And yes I do know I posted the same question yesterday... I still cannot figure this one out. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Array HELL!!!!
Ok, you have almost got it. I have made little remarks further down in your code which should just about do it for you. jas [EMAIL PROTECTED] said: I don't know what it is but I am having a hell of a time trying to get some results of a query setup into an array or variable (too much of a newbie to know which) that can be passed to a confirmation page before deleting the record from a table. I have given up working on this but for those of you that want to finish it here is the code and the table structure... [Table Structure] id int(30) DEFAULT '0' NOT NULL auto_increment, car_type varchar(30), car_model varchar(30), car_year varchar(15), car_price varchar(15), car_vin varchar(25), dlr_num varchar(25), PRIMARY KEY (id) [Page 1 - Queries DB table for records] ?php require '../path/to/db.php'; $result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not execute query, please try again later); echo table border=\0\ class=\table-body\ width=\100%\form name=\rem_inv\ method=\post\ action=\rem_conf.php3\ trtd align=\center\ colspan=\3\font size=\4\BCurrent Inventory/B/fonthr color=\33\/td/tr; $count = -1; $count should start at 0 and then increment at the bottom of the while loop while ($myrow = mysql_fetch_array($result)) { $id = $row[id]; $row should be $myrow since that is what it is called above (or change $myrow above to $row) $car_type = $row[car_type]; $car_model = $row[car_model]; $car_year = $row[car_year]; $car_price = $row[car_price]; $car_vin = $row[car_vin]; $count ++; $count ++; should be moved to the bottom of the loop just before it is closed echo trtd width=\30%\BType Of Car: /B/tdtd; printf(mysql_result($result,$count,car_type)); mysql_result is not needed here, you have defined the variable $car_type to be this here as well as the rows below, so replace mysql_result($result, $count, car_type) with just $car_type echo /tdtdinput type=\checkbox\ name=\id[]\ value=\.$myrow[id].\remove/td/tr\n; replace $myrow[id] with $id since it is already defined above when id[] is passed to page 2, it will contain an array of the id numbers that got checked echo trtd width=\30%\BModel Of Car: /B/tdtd; printf(mysql_result($result,$count,car_model)); same as above, replace mysql_result($result,$count,car_model) with $car_model echo /td/tr\n; echo trtd width=\30%\BYear Of Car: /B/tdtd; printf(mysql_result($result,$count,car_year)); same as above replace with $car_year echo /td/tr\n; echo trtd width=\30%\BPrice Of Car: /B/tdtd$; printf(mysql_result($result,$count,car_price)); same as above replace with $care_price echo /td/tr\n; echo trtd width=\30%\BVIN Of Car: /B/tdtd; printf(mysql_result($result,$count,car_vin)); same as above replace with $car_vin echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n; $count ++; should go here } echo trtdinput type=\submit\ name=\delete\ value=\delete\/td/tr/form/table; ? [Page 2 - Takes records and confirms which ones to be deleted] ?php print( table border=\0\ class=\table-body\ width=\100%\ form name=\rem_inv\ method=\post\ action=\done2.php3\ send id[] array passed from previous page to the next page: INPUT TYPE=\hidden\ NAME=\id[]\ VALUE=\$id[]\ If you are planning on deleting multiple items at a time, you won't need the following hidden elements at all, just make a database call at this point using the id[] array passed to this page from the first page. The only value it needs for the 3rd page is the id value since that is what it uses to determine what to delete. Here is an example of the database call to make: $i=0; while ($id[$i]) { $result = @mysql_query(SELECT * FROM cur_inv where id=$id[$i],$dbh) or die (Could not execute query, please try again later); $row=mysql_fetch_array($result); $car_type=$row['car_type']; $car_model=$row['car_model']; $car_year=$row['car_year']; $car_price=$row['car_price']; $car_vin=$row['car_vin']; INPUT TYPE=\hidden\ NAME=\id\ VALUE=\$id\ INPUT TYPE=\hidden\ NAME=\car_type\ VALUE=\$car_type\ INPUT TYPE=\hidden\ NAME=\car_model\ VALUE=\$car_model\ INPUT TYPE=\hidden\ NAME=\car_year\ VALUE=\$car_year\ INPUT TYPE=\hidden\ NAME=\car_price\ VALUE=\$car_price\ INPUT TYPE=\hidden\ NAME=\car_vin\ VALUE=\$car_vin\ tr td align=\center\ colspan=\3\font size=\4\BConfirm Record Deletion/B/fonthr color=\33\/td /tr tr td width=\30%\BType Of Car: /B/td td$car_type/td /tr tr td width=\30%\BModel Of Car: /B/td td$car_model/td /tr tr td width=\30%\BYear Of Car: /B/td td$car_year/td /tr tr td width=\30%\BPrice Of Car: /B/td td$car_price/td /tr tr td width=\30%\BVIN Of Car: /B/td td$car_vin/td /tr $i++; end loop here or after hr (wherever you prefer if you want hr between each item end after hr) ?}? tr td colspan=\3\hr color=\33\/td /tr tr tdinput type=\submit\ name=\delete\ value=\delete\/td
Re: [PHP-DB] Parse Error
Is $cars an array field? If not, you are trying to compare $cars to an list/array of values (I am not sure this would work even if $cars was an array field) 'WHERE $cars = $car_type\,\$car_model\,\$car_year\,\$car_price\,\$car_vin\,\$dlr _num\);'. Normally, you would have to compare each individual value in each requested field to a variable. Hard to say without more code. MB jas [EMAIL PROTECTED] said: I hate to post this again but I have looked in a couple of php and mysql books but cannot seem to figure this one out. I am getting a parse error when trying to use php to delete records from a table. The error I am recieving is as follows Parse error: parse error in /path/to/php/done2.php3 on line 22 Here is the file that is giving me the error, any help would be great... I think that my problem is that I left out a variable to hold the $cars data but I am not sure. Here is the code... $db_name = test; $table_name = inventory; $connection = @mysql_connect(localhost, root, password) or die (Could not connect to database. Please try again later.); $db = @mysql_select_db($db_name,$connection) or die (Could not select database table. Please try again later.); $sql = DELETE FROM $table_name WHERE $cars = \$car_type\,\$car_model\,\$car_year\,\$car_price\,\$car_vin\,\$dl r_num\); $result = @mysql_query($sql, $connection) or die (Could not execute query. Any insight would be great... thanks again. Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Parse Error
According to your code, if the checkbox next to the word 'remove' is checked, then the value of $cars passed to the form is checkbox. Then in the done2.php3 page, you are trying to delete where checkbox='array of values listed'. Is there a field in your database called checkbox? If so, what field type is it set to? If not, there is your problem. HTH MB jas [EMAIL PROTECTED] said: Here is the code from the file that queries the db and pulls the current contents of the db and provides a check box form for each record to delete the items in the db. I dont know if this will help but like I said before any insight would be great. Thanks in advance. Jas ?php require '../scripts/db.php'; $result = mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not execute query, please try again later); echo table border=\0\ class=\table-body\ width=\100%\form name=\rem_inv\ method=\post\ action=\done2.php3\ trtd align=\center\ colspan=\3\font size=\4\BCurrent Inventory/B/fonthr color=\33\/td/tr; $count = -1; while ($myrow = mysql_fetch_row($result)) { $count ++; echo trtd width=\30%\BType Of Car: /B/tdtd; printf(mysql_result($result,$count,car_type)); echo /tdtdinput type=\checkbox\ name=\cars\ value=\checkbox\remove/td /tr\n; echo trtd width=\30%\BModel Of Car: /B/tdtd; printf(mysql_result($result,$count,car_model)); echo /td/tr\n; echo trtd width=\30%\BYear Of Car: /B/tdtd; printf(mysql_result($result,$count,car_year)); echo /td/tr\n; echo trtd width=\30%\BPrice Of Car: /B/tdtd$; printf(mysql_result($result,$count,car_price)); echo /td/tr\n; echo trtd width=\30%\BVIN Of Car: /B/tdtd; printf(mysql_result($result,$count,car_vin)); echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n; } echo trtdinput type=\submit\ name=\delete\ value=\delete\/td/tr/form/table; ? After this file is pulled and the user selects which record to delete it jumps to the other snippit of code in done2.php3 which is $db_name = test; $table_name = inventory; $connection = @mysql_connect(localhost, root, password) or die (Could not connect to database. Please try again later.); $db = @mysql_select_db($db_name,$connection) or die (Could not select database table. Please try again later.); $sql = DELETE FROM $table_name WHERE $cars = \$car_type\,\$car_model\,\$car_year\,\$car_price\,\$car_vin\,\$dl r_num\); $result = @mysql_query($sql, $connection) or die (Could not execute query. Any insight would be great... thanks again. Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] debugging?
Here is what your delete statement should look like: $sql = mysql_query(DELETE FROM $table_name WHERE id = '$id',$dbh) or die(mysql_error()); Note the field name without the $ in front of it and the variable you are comparing it to with the $. One other note, in your table, you have id as a varchar(30) auto_increment. As far as I know, auto_increment can only be used on INT() field types, unless I missed something there. If you do end up changing the field type to INT, make sure you take the '' around the $id out. HTH MB jas [EMAIL PROTECTED] said: Ok now that I can see the error message how can I fix it... the syntax looks correct and the error I am recieving is as follows You have an error in your SQL syntax near '= 'id'' at line 1 And this is my statement, $sql = mysql_query(DELETE FROM $table_name WHERE $id = 'id',$dbh) or die(mysql_error()); Is there anywhere on php.net or mysql.org that give exact error meanings? Thanks again, Jas Olinux [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... jas, Try this: - Remove the @, it suppresses the error - change die(Could not execute query, please try again later); to die(mysql_error()); $sql = mysql_query(DELETE FROM $table_name WHERE $id = 'id',$dbh) or die(mysql_error()); olinux --- jas [EMAIL PROTECTED] wrote: Can someone tell me how I can find out why I am getting errors executing queries when I try to delete items from a table? I have 2 files... file 1. - Queries database, displays results with option to delete record using a check box, code is as follows... ?php snip __ Do You Yahoo!? Yahoo! Sports - Coverage of the 2002 Olympic Games http://sports.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] debugging?
Your $sql already contains a mysql_query. Why are you running it against it again, unless you have changed something. If $sql only contains your delete statement(without calling mysql_query), then do not put quotes around $sql,$dbh Otherwise, come back with what $sql and $dbh are assigned to be. That would probably help determine what the problem is. MB jas [EMAIL PROTECTED] said: Ok now that the sql statement is working I am getting an error on my result function... here is the result function $result = mysql_query($sql, $dbh) or die(mysql_error()); and here is the error I am recieving You have an error in your SQL syntax near '1, 1' at line 1 I dont know enough about php and mysql to understand what this means... is there some kind of chart or definitions for error messages? I tried looking on mysql.org and couldnt find anything specific. In any event, thanks in advance. Jas [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Here is what your delete statement should look like: $sql = mysql_query(DELETE FROM $table_name WHERE id = '$id',$dbh) or die(mysql_error()); Note the field name without the $ in front of it and the variable you are comparing it to with the $. One other note, in your table, you have id as a varchar(30) auto_increment. As far as I know, auto_increment can only be used on INT() field types, unless I missed something there. If you do end up changing the field type to INT, make sure you take the '' around the $id out. HTH MB jas [EMAIL PROTECTED] said: Ok now that I can see the error message how can I fix it... the syntax looks correct and the error I am recieving is as follows You have an error in your SQL syntax near '= 'id'' at line 1 And this is my statement, $sql = mysql_query(DELETE FROM $table_name WHERE $id = 'id',$dbh) or die(mysql_error()); Is there anywhere on php.net or mysql.org that give exact error meanings? Thanks again, Jas Olinux [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... jas, Try this: - Remove the @, it suppresses the error - change die(Could not execute query, please try again later); to die(mysql_error()); $sql = mysql_query(DELETE FROM $table_name WHERE $id = 'id',$dbh) or die(mysql_error()); olinux --- jas [EMAIL PROTECTED] wrote: Can someone tell me how I can find out why I am getting errors executing queries when I try to delete items from a table? I have 2 files... file 1. - Queries database, displays results with option to delete record using a check box, code is as follows... ?php snip __ Do You Yahoo!? Yahoo! Sports - Coverage of the 2002 Olympic Games http://sports.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] query error...
Try putting single quotes around your variables in your update statement instead of the escaped double quotes, they are easier to read. Also, were you wanting to update all entries in that table to the same, c_name, s_addy, city, state, zip and phone? If not, you will need to add 'where id=$id' (or something along those lines) to your update statement. Otherwise, the way you have it now, it will update every row in your database to the same values for the listed fields. jas [EMAIL PROTECTED] said: Ok what is wrong with this sql statement? $sql = UPDATE $table_name SET c_name=$c_name,s_addy=$s_addy,city=$city,state=statezip=zi p,phone=$phone; The error I recieve is as follows Warning: Unexpected character in input: '' (ASCII=92) state=1 in /path/to/wwwdemo_change.php3 on line 22 Parse error: parse error in /path/to/wwwdemo_change.php3 on line 22 I have looked on MySQL.com at the update function and it states I can use the SET under UPDATE for multiple fields separated by a , and it is not working... Any insight would be great. Thanks in advance, Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] SELECT statement does not return rows
Is your id an integer or a char/varchar? If it is an integer, take the quotes off $id in your select statement. Todd Williamsen [EMAIL PROTECTED] said: Weird.. I want to be able to edit records, which I have done in the past, and I cannot see why it isn't working... I have tried single qoutes around the $row = and that doesn't work either. here is the code: $db = @mysql_select_db($db_name, $connection) or die(Could not select database); $sql=SELECT * FROM Jobs WHERE id = '$id' ; $result = mysql_query($sql,$connection) or die(Couldn't execute query); while ($row = mysql_fetch_array($result)) { $id = $row[id]; $Industry = $row[Industry]; $Other = $row[Other]; $JobTitle = $row[JobTitle]; $Description = $row[Description]; $Location = $row[Location]; $Date = $row[Date]; } ? html head TitleEdit Job Posting/title /head body h1Edit Job Posting/h1 form method=post action=do_mod_job.php input type=hidden name=id value=? echo $id; ? table cellspacing=3 cellpadding=5 align=center tr thJob Information and Location/th thJob Description/th /tr tr td valign=top pstrongJob Title:/strongbr input type=text name=JobTitle value=?php echo $JobTitle? size=50 maxlength=75/p pstrongIndustry:/strongbr input type=text name=Industry value=? echo $Industry; ? size=50 maxlength=75/p pstrongOther:/strongbr input type=text name=Other value=? echo $Other;? size=50 maxlength=75/p pstrongLocation:/strongbr inout type=text name=Location value=? echo $Location; ? size=50 maxlength=75/p pstrongDate:/strongbr input type=text name=Date value=? echo $Date; ? size=30 maxlength=40/p /td td valign=top pstrongDescription:/strongbr textarea name=Description cols=50 rows=10? echo $Description; ?/textarea /p /td /tr tr td align=center colspan=2br pinput type=submit name=submit value=Update Job/p br /td /tr /table /form /body /html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Select statement only returns 1 record
You will need to put the option tag in a loop to get all of the records in the table. select name=canidate (this can go anywhere but in while loop) ? $db = mysql_connect($dbserver, $dbuser, $dbpass); mysql_select_db($dbname,$db); $sortby = name ASC; $sql=SELECT * FROM webl_players ORDER BY $sortby; $result=mysql_query($sql,$db); $num=mysql_numrows($result); $i=0; while ($i $num) { $row = mysql_fetch_array($result); $FirstName = $row[FirstName]; $LastName = $row[LastName]; echo option value='$LastName, $FirstName'?php echo '$LastName, $FirstName'?/option; $i++; } ? Also, without the value in the option tag, you will not be passing anything to the form. HTH Maureen Biorn Todd Williamsen [EMAIL PROTECTED] said: I am trying to get data from two columns, FirstName and Last name and displaying all the records LastName, FirstName in a drop down menu. The weird thing is that it only displays one record. I thought the table was hosed, but its not. I tried it through another database and still doesn't work. Here is the code: ? $db = mysql_connect($dbserver, $dbuser, $dbpass); mysql_select_db($dbname,$db); $sortby = name ASC; $sql=SELECT * FROM webl_players ORDER BY $sortby; $result=mysql_query($sql,$db); $row = mysql_fetch_array($result); $FirstName = $row[FirstName]; $LastName = $row[LastName]; ? select name=canidate option selected ?php echo $LastName, $FirstName; ? /option I would list the whole page but its long! There is another SQL statement at the top of the page: ?php $db = mysql_connect($dbserver, $dbuser, $$dbpass); mysql_select_db($dbname, $db); $sql = SELECT * FROM Canidate SORT BY 'LastName'; $result = mysql_query($sql); ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] PHP query on date field
Isn't date a reserved word that should not be used as a field name? It appeared that what was asked was if he should change the name of his field from date to date_1. It should definitely be changed if it is now called date. Jason Wong [EMAIL PROTECTED] said: On Wednesday 31 October 2001 01:31 am, Jason wrote: Here is my problem once again... =P I am wondering if I should change the date table to something other than date... maybe something like date_1? Would doing that resolve my issue, because of the fact that the date variable in php is function? Thanks in advance... What is the format of date as defined in your database? If date is of type DATE or DATETIME then $result = mysql_query (SELECT * FROM ads WHERE fname LIKE '%$fname%' AND lname LIKE '%$lname%' AND phonea LIKE '%$phonea%' AND phone LIKE '%$phone%' AND date LIKE '%$date%'); should be changed to: $result = mysql_query (SELECT * FROM ads WHERE fname LIKE '%$fname%' AND lname LIKE '%$lname%' AND phonea LIKE '%$phonea%' AND phone LIKE '%$phone%' AND date = '$date' ); hth -- Jason Wong Gremlins Associates www.gremlins.com.hk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] HELP PLEASE!! Get query error when inserting into MySql
If any of the values you are trying to insert are not integers, you need to put single quotes around the variables, ie. $SCRIPT_NAME, $date, $BName, etc in the insert statement. Robby Whiteside [EMAIL PROTECTED] said: Hi There, I have a query whenever I try to insert something into a mysql table. This is the code I am using: ? $host1 = gethostbyaddr($REMOTE_ADDR); $date = date(Y-m-d h:i:s); $link = mysql_connect($host, $user, $passwd); mysql_select_db($database, $link); $sql = INSERT INTO vcstats VALUES('', $SCRIPT_NAME, $date, $HTTP_USER_AGENT, $BName, $BVersion, $BPlatform, $REMOTE_ADDR, $host1); $result = mysql_query($sql) or die(query errorBr . mysql_error()); mysql_close(); ? Thanks, Robby - This message was sent using Endymion MailMan. http://www.endymion.com/products/mailman/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Re: NEWBIE - Needs Assistance with Joins
You should not need the extra semicolon in there to complete the SQL statement. All you need is the one at the end. Vera Algoet [EMAIL PROTECTED] said: Cecily, I'm sure you probably heard from others about your parse error. I know it looks weird, but you need to have two semicolons, so instead of: $CDList =mysql_query( SELECT artist_name, album_title . FROM artists, album_titles WHERE artist_id = aid); you would have $CDList =mysql_query( SELECT artist_name, album_title . FROM artists, album_titles WHERE artist_id = aid;); (Note the semicolon after aid). This is because the first one is to complete the SQL statement, while the one after the parenthisis is to complete the PHP statement. Vera --- Madness takes its toll. Please have exact change. Vera Algoet, Web Developer Monterey County Office of Education 831-784-4169 -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] example of making Next 10 entries - previous ..
Here is an excellent example at PHPBuilder (a great site for finding tutorials) http://www.phpbuilder.com/columns/rod2221.php3 HTH Maureen Andrius Jakutis [EMAIL PROTECTED] said: Hello, I need example of making simple thing: to list only 10 entries per page, and next 10 is shown after next page button is clicked. Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Re: PHP4, MySQL, errors....
It appears that the error is pointing to the last line of your code (just by a quick count of the lines). This normally means that you are missing a closing bracket somewhere in your code.In glancing through your code, the first while statement has an opening, but no closing bracket (unless that is a typo). I also noted that your second while statement has no opening or closing brackets. HTH Maureen Cato Larsen [EMAIL PROTECTED] said: Hey! Thanks for the help Mr. Bothwell. But now it seems I get a new error: Parse error: parse error in C:Program FilesApache GroupApachehtdocs/oiamemb/members.php on line 89 I don't know why, or if it's the MySQL database who's moching with me. The current source is as follows: (Guess I've screwed it up worse than ever...) Thanks to all the people who have helped me. This is my first try at PHP, and MySQL for that matter so I realy apreciate it! Best regards Cato Code start ? $usr = Xephiroth; $pwd = lordoftherings; $db = members; $host = localhost; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid) { echo Error: .mysql_error(); exit; } ? html head titleProfiles/title meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /head body bgcolor=#00 text=#FF leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 background=../images/back.gif bgproperties=fixed ? $str = PHP is not running!; echo substr($str, 0, 7) . substr($str, 11); ? ? $prof = Nano-Technician; # setup SQL statement $SQL = SELECT * FROM memberinfo ; $retid = mysql_db_query($db, $SQL, $cid); # check for errors if (!$retid) { echo( mysql_error()); } else { # display results while ($row = mysql_fetch_array($retid)) { $email = $row[email]; $loc = $row[loc]; $aim = $row[aim]; $icq = $row[icq]; $msn = $row[msn]; $yahoo = $row[yahoo]; $charname = $row[charname]; $charsname = $row[charsname]; $charnick = $row[charnick]; $tit = $row[tit]; $lvl = $row[lvl]; $picurl = $row[picurl]; $born = $row[born]; $apperiance = $row[apperiance]; $charac = $row[charac]; $streng = $row[streng]; $bio = $row[bio]; $breed = $row[breed]; $prof = $row[prof]; $posn = $row[posn]; $contents = row(cell(, 150) . cell(, 200) . cell(, 200)); while ($row = mysql_fetch_array($retid)) $contents .= row( cell(img src='{$row[picurl]}') .cell( bold( {$row[tit]} {$row[charname]} .quot;{$row[charnick]}quot; .{$row[charsname]} ).br .bold(Contact: ).$row[email].br .bold(Level: ).$row[lvl].br .bold(Breed: ).$row[breed].br .bold(Profession: ).$prof.br .bold(Location: ).$row[loc].br .bold(AIM: ).$row[aim].br .bold(ICQ: ).$row[icq].br .bold(MSN: ).$row[msn].br .bold(Yahoo!: ).$row[yahoo].br ) .cell( br .bold(Born: ).$row[born].br .bold(Appearance: ).$row[appearance].br .bold(Position: ).$row[posn].br .bold(Characteristics: ).$row[charac].br .bold(Strengths/weaknesses: ).$row[streng].br .bold(Bio: ).$row[bio].br ) ); echo table($contents); ) ? /body /html -- Code end -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Problem importing large db to mysql in windows
It sounds like the problem you are having is the same one I had. There is a variable in the php.ini called upload_max_filesize that the default max size in here is 2Mb, so when importing or exporting a dump file that is over 2Mb, it will not work. Try changing this in your php.ini file and see if that fixes it. You may need to restart the server that PHPMyAdmin is running on to get it to register. Let us know if it still does not work. Thanks. Maureen Biorn Doug Schasteen [EMAIL PROTECTED] said: I'm running a local web server for development on my Win ME machine using apache, mysql 3.23.38, and php4. I've been copying my mysql database that is online to my local one every once in a while. When the database starting getting greater than 1mb I remember the mysql filename.sql wouldn't work anymore and I had to use mysqldump filename.sql to dump the db to a file. I always used phpMyAdmin to run the sql file and import everything to my local db. My problem is that now my database is greater than 2mb and phpMyAdmin no longer wants to run my .sql file. It just skips straight to SQL command executed successfully but says No Tables, so obviously it isn't even trying to run the file. This is almost exactly what was happening on the dump end before I started using mysqldump. So, what's the IMPORT equivalent of mysqldump and how do I run it on windows? - Doug Schasteen -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Problem importing large db to mysql in windows
I have several files I import daily using phpMyAdmin, the biggest of which is over 4Mb and it only takes 5-10 seconds, but both machines (my pc-750Mhz Win98 and the server) are on the same network. If you are using dialup to access it, that could be why it is taking longer. Otherwise, I would look somewhere else for the problem. Maureen Biorn Doug Schasteen [EMAIL PROTECTED] said: It works great! However, even though my .sql file was only 2.4 mb, it took nearly 15 minutes to import it all. I expect to be working with 20mb files in the not too distant future. Will it really take over two hours? Is this mysql's fault or the fault of my POS 500mhz WinME machine? Anyone know? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 01, 2001 10:41 AM To: Doug Schasteen; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Problem importing large db to mysql in windows It sounds like the problem you are having is the same one I had. There is a variable in the php.ini called upload_max_filesize that the default max size in here is 2Mb, so when importing or exporting a dump file that is over 2Mb, it will not work. Try changing this in your php.ini file and see if that fixes it. You may need to restart the server that PHPMyAdmin is running on to get it to register. Let us know if it still does not work. Thanks. Maureen Biorn Doug Schasteen [EMAIL PROTECTED] said: I'm running a local web server for development on my Win ME machine using apache, mysql 3.23.38, and php4. I've been copying my mysql database that is online to my local one every once in a while. When the database starting getting greater than 1mb I remember the mysql filename.sql wouldn't work anymore and I had to use mysqldump filename.sql to dump the db to a file. I always used phpMyAdmin to run the sql file and import everything to my local db. My problem is that now my database is greater than 2mb and phpMyAdmin no longer wants to run my .sql file. It just skips straight to SQL command executed successfully but says No Tables, so obviously it isn't even trying to run the file. This is almost exactly what was happening on the dump end before I started using mysqldump. So, what's the IMPORT equivalent of mysqldump and how do I run it on windows? - Doug Schasteen -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] MySQL Error???
Most likely, your id (index, auto-increment field, whatever it is) data type is tinyint which only goes to 127. Brian Grayless [EMAIL PROTECTED] said: Is anyone familiar with this MySQL error? 1062: Duplicate entry '127' for key 1 I wrote a great bookmark management program that works fine, but everytime I insert bookmarks, I insert somewhere over 120 and I start getting this error, and it won't add them anymore. Any suggestions??? Thanks, B R I A N G R A Y L E S S Web Administrator Premier Resorts www.premier-resorts.com P: 435-655-4812 F: 413-618-1518 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Data errors in entering
The problem is in your insert statement. You forgot the $ on your month and year variable values. Your statement should read: $sql = INSERT INTO $table_name (day,daydate,month,year,time,place,numbers, details,reportby) VALUES ('$day',$daydate,$month,$year,'$time','$place','$numbers','$details','$reportby'); ^ ^ Another note, you do not need the quotes around your integer values for $daydate, $month, $year. You also should use single quotes on the other values rather than double quotes. Shane Barry [EMAIL PROTECTED] said: I seem to be having a problem with a php script I use to enter data into a sql database from a php frontend. The data are ints (months and years as a number). The Database is : +--+-+--+-+-+---+ | Field| Type| Null | Key | Default | Extra | +--+-+--+-+-+---+ | day | text| YES | | NULL| | | daydate | int(11) | YES | | NULL| | | month| int(11) | YES | | NULL| | | year | int(11) | YES | | NULL| | | time | text| YES | | NULL| | | place| text| YES | | NULL| | | numbers | text| YES | | NULL| | | details | text| YES | | NULL| | | reportby | text| YES | | NULL| | +--+-+--+-+-+---+ The html file takes the data in as (Using the post method): PSTRONGDATE:/STRONGBR INPUT TYPE=int NAME=daydate SIZE=10 MAXLENGTH=10/p PSTRONGMONTH:/STRONGBR INPUT TYPE=int NAME=month SIZE=10 MAXLENGTH=10/p PSTRONGYEAR:/STRONGBR INPUT TYPE=int NAME=year SIZE=10 MAXLENGTH=10/p and the php script interacts with the data as: $sql = INSERT INTO $table_name (day, daydate, month, year, time, place, numbers, details, reportby) VALUES ($day, $daydate, month, year, $time, $place,$numbers,$details, $reportby) ; The Sections affected are month and year all the others including daydate which is exactly the same are working. Can someone please point out the error to me? Shane -- Webmaster Dublin Wicklow Mountain Rescue Team www.dwmrt.ie Irish Mountain Rescue Association imra.ie.eu.org ICQ # 103528846 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]