Re: [PHP] PHP MySQL Insert Statements
2010/3/12 Martine Osias webi...@gmail.com Hi, My insert statements on this web page don't execute. The select statements do work. This tells me that the database connection is working. The username and password are the administrator's. What else could prevent the insert statements from executing? The assigned permissions to that account. Using MySQL, you can define *who* is allowed to do *what*. (i.e. SELECT, INSERT, GRANT) (or syntax errors in your insert statements, like others said before.) Regards
Re: [PHP] PHP MySQL Insert Statements
Always make sure your dynamic sql string in php code are as expected var_dump($sql) before query On Thu, Mar 11, 2010 at 10:13 PM, Martine Osias webi...@gmail.com wrote: Hi, My insert statements on this web page don't execute. The select statements do work. This tells me that the database connection is working. The username and password are the administrator's. What else could prevent the insert statements from executing? Thank you. Martine -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP MySQL Insert Statements
Hi, My insert statements on this web page don't execute. The select statements do work. This tells me that the database connection is working. The username and password are the administrator's. What else could prevent the insert statements from executing? Thank you. Martine -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP MySQL Insert Statements
2010/3/11 Martine Osias webi...@gmail.com: Hi, My insert statements on this web page don't execute. The select statements do work. This tells me that the database connection is working. The username and password are the administrator's. What else could prevent the insert statements from executing? Would you mind giving us some hints about how the INSERT statements looks like? Thanks. Thank you. Martine -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP MySQL Insert Statements
Martine Osias wrote: My insert statements on this web page don't execute. The select statements do work. This tells me that the database connection is working. The username and password are the administrator's. What else could prevent the insert statements from executing? Most likely syntax of the insert statement. Do your insert statements work if used in MySQL Query Browser? What is MySQL returning? Are you using OOP or old functions? Have you tried having PHP echo your insert statement so you can see exactly what you are sending MySQL? Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP MySQL Insert Statements
Martine Osias wrote: Hi, My insert statements on this web page don't execute. The select statements do work. This tells me that the database connection is working. The username and password are the administrator's. What else could prevent the insert statements from executing? Thank you. Martine Should be trivial to find out what's happening. Something like: $success=mysql_query($insert_statement) or die(Uh-oh, mysql said:.mysql.error()); HTH, Kevin Kinsey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP MySQL Insert Syntax
/*I'm trying to insert values from an array into MySQL DB but the insert begins at the last record in the table and not at first record in the table. I have added the cellSuffixes column after I already populated 30 records in other columns*/ Code: foreach($list as $key=$value) { $query = INSERT INTO carriers (cellSuffixes) VALUES('$value'); mysql_query($query,$connex) or die(Query failed: . mysql_error($connex)); } echo done; mysql_close($connex); //I don't know what the sytax s/b to get the data to be inserted in the first row of the column. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP MySQL Insert Syntax
Insert is for a new row Alter or Update is for an exsisting row /*I'm trying to insert values from an array into MySQL DB but the insert begins at the last record in the table and not at first record in the table. I have added the cellSuffixes column after I already populated 30 records in other columns*/ Code: foreach($list as $key=$value) { $query = INSERT INTO carriers (cellSuffixes) VALUES('$value'); mysql_query($query,$connex) or die(Query failed: . mysql_error($connex)); } echo done; mysql_close($connex); //I don't know what the sytax s/b to get the data to be inserted in the first row of the column. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP MySQL Insert Syntax
Thanks :-) [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Insert is for a new row Alter or Update is for an exsisting row /*I'm trying to insert values from an array into MySQL DB but the insert begins at the last record in the table and not at first record in the table. I have added the cellSuffixes column after I already populated 30 records in other columns*/ Code: foreach($list as $key=$value) { $query = INSERT INTO carriers (cellSuffixes) VALUES('$value'); mysql_query($query,$connex) or die(Query failed: . mysql_error($connex)); } echo done; mysql_close($connex); //I don't know what the sytax s/b to get the data to be inserted in the first row of the column. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP MySQL insert
Please help with an insert problem. Sometimes $data1 could have a comma and that messes up the insert. how do I get around that? $query = insert into testtable6 (indx, col1, col2) values (NULL, '$data1', '$data2'); mysql_db_query(testdb, $query); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP MySQL insert
You need to escape the data, so $data1 = mysql_real_escape_string($data1,$rLink); $data2 = mysql_real_escape_string($data2,$rLink); Jon wrote: Please help with an insert problem. Sometimes $data1 could have a comma and that messes up the insert. how do I get around that? $query = insert into testtable6 (indx, col1, col2) values (NULL, '$data1', '$data2'); mysql_db_query(testdb, $query); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP MySQL insert
besides just escaping your strings, i think you are having a quoting error: http://www.php.net/manual/en/language.types.string.php Commas should not have to be escaped, and indeed the mysql_real_escape_string() function will not escape commas. After escaping your input data with this function, I would make the $query text a bit more technically correct: Change this: $query = insert into testtable6 (indx, col1, col2) values (NULL, '$data1', '$data2'); to this: $query = insert into testtable6 (indx, col1, col2) values (NULL, '. $data1.', '.$data2.'); echo $query.br\n; to ensure proper handling of all data in the sql commands. If you echo your $query before the insert, what do you get? This is always a good practice when you're having trouble. Jordan On Aug 18, 2005, at 12:05 PM, Chris wrote: You need to escape the data, so $data1 = mysql_real_escape_string($data1,$rLink); $data2 = mysql_real_escape_string($data2,$rLink); Jon wrote: Please help with an insert problem. Sometimes $data1 could have a comma and that messes up the insert. how do I get around that? $query = insert into testtable6 (indx, col1, col2) values (NULL, '$data1', '$data2'); mysql_db_query(testdb, $query); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php-mySQL insert problem
Hi, I'm new in php so like usual I have little problem(s). I have DB clas who connect to database, select database, query database and so on. I have other class User with some members. exemple: ... var $firstName; var $lastName; ... Then I need to insert created object into mySQL database doing something like this: INSERT into TABLE values ($this - firstName, $this - lastName); I do that this way: $insertQuery = Insert into TABLE values (.$this - firstName.,.$this - lastName)); $db = new DB; $db - query($insertQuery); this is not working and I have next message: Parse error: parse error, unexpected T_OBJECT_OPERATOR in /Library/Apache2/htdocs/Users.php on line 80 I think that my error is in escape characters and I dont not know hox to resolve my problem. Any help is welcome. Thanks in advance ADI -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-mySQL insert problem
Try this: $insertQuery = Insert into TABLE ( col_one, col_two )values ( ' . $this - firstName . ', ' . $this- lastName . ' ); $db = new DB; $res = $db-query($insertQuery); if(DB::isError($res)){ exit(Insert query failed: .__FUNCTION__.() brin file .__FILE__.bron line .__LINE__.br.$res-getDebugInfo()); }else{ return; } you need to have quotes arround your varchar items and you should also specify which column you want the values to go into. It is also good practice to check if there is an error and try to get the most information available. On Tue, 2005-08-02 at 00:44 +0200, Adi Zebic wrote: $insertQuery = Insert into TABLE values (.$this - firstName.,.$this - lastName)); $db = new DB; $db - query($insertQuery); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: SOLVED - [PHP] php-mySQL insert problem
Jack Scott a écrit : Try this: $insertQuery = Insert into TABLE ( col_one, col_two )values ( ' . $this - firstName . ', ' . $this- lastName . ' ); $db = new DB; $res = $db-query($insertQuery); if(DB::isError($res)){ exit(Insert query failed: .__FUNCTION__.() brin file .__FILE__.bron line .__LINE__.br.$res-getDebugInfo()); }else{ return; } you need to have quotes arround your varchar items and you should also specify which column you want the values to go into. Yess! That's the right one :-) It is also good practice to check if there is an error and try to get the most information available. DB class do the right thing with try/catch. THANK YOU VERY VERY MUCH Jack Scott! ADI -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: SOLVED - [PHP] php-mySQL insert problem
no prob ;-) On Tue, 2005-08-02 at 02:27 +0200, Adi Zebic wrote: Jack Scott a écrit : Try this: $insertQuery = Insert into TABLE ( col_one, col_two )values ( ' . $this - firstName . ', ' . $this- lastName . ' ); $db = new DB; $res = $db-query($insertQuery); if(DB::isError($res)){ exit(Insert query failed: .__FUNCTION__.() brin file .__FILE__.bron line .__LINE__.br.$res-getDebugInfo()); }else{ return; } you need to have quotes arround your varchar items and you should also specify which column you want the values to go into. Yess! That's the right one :-) It is also good practice to check if there is an error and try to get the most information available. DB class do the right thing with try/catch. THANK YOU VERY VERY MUCH Jack Scott! ADI -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php