Re: [PHP] Code check
Paul Goepfert wrote: ... What this script does is selects tomorrows date... Here is a one-line way to find the month and day of tomorrow: list($tomorrow_month, $tomorrow_day) = split(':', date('m:d', time()+86400)); ?> Test that ... I just wrote it off the top of my head. Maybe that will simplify your code. Dante -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Code check
Hi all, I wrote a php script that creates options for select boxes. What this script does is selects tomorrows date. However I have tested the code when the day is the last day of the month and the script blows up. Instead of displaying June it displays January and repeats the months 12 times I think. I didn't count I just noiced thart that the months of the year were repeated multiple times. I think my problem is with the mktime function. I don't think it likes $i+1 too well. I also want to be sure that this code takes care of all date contitions like leap year, end of the year and any other condition that would give a wrong date. So here is my code: " . date('F', mktime(12,0,0,$i+1,1)) . "\n"; } if (date('n') == $i) { echo "" . date('F', mktime(12,0,0,$i,1)) . "\n"; } else { echo "" . date('F', mktime(12,0,0,$i,1)) . " \n"; } } ?> " . date('j', mktime(12,0,0,0,$i,date('Y'))) . "\n"; } else { echo "" . date('j', mktime(12,0,0,0,$i,date('Y'))) . "\n"; } } ?> " . date('Y')+1 . "\n"; } else { echo "" . date('Y') . "\n"; } ?> Any help will be appreciated Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code Check
On 5/30/05, janbro <[EMAIL PROTECTED]> wrote: > Hi List, I don't know where else to look. I've got PHP 5.0.0 and MySQL > 4.1.3. (on Windwows XP with Apache 2.0.50) > > Here is my Code: the Query with the delete is not executed and I don't > know why. If I copy it into the MySQL Command line like it is here, > everything works fine. I have another example with a more simple delete > which works (same syntax) > > If I replace the delete with the insert statement it works. > > What 'am I doing wrong here? > > > > > public function DeleteOldFails (){ > > $conClas=$this->con(); > > $con=$conClas->mysqlConnect (); > > > > $query = "DELETE FROM LoginTracker WHERE > > (UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - UNIX_TIMESTAMP(DateAttack)) > 3600;"; > > //$query ="INSERT INTO LoginTracker (IPAttack, User) VALUES > > ('127.0.0.1','user')"; > > echo "$conDiesen Auf ERFOLG TESTEN! LÖSCHT ER WAS ER > > SOLL? $query"; > > print $con->query($query); > > $con->query("OPTIMIZE TABLE LoginTracker "); > > > > $this->discon ($conClas, $con); > > } > > thx > janbro > -snip- $query = "DELETE FROM LoginTracker WHERE (UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - UNIX_TIMESTAMP(DateAttack)) > 3600;"; -snip- Take out that ; after the 3600! Dotan Cohen http://lyricslist.com/lyrics/pages/artist_albums.php/345/Metallica -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code Check fixed
Ok, thx, I've got it done. Dumb mistake, the user didn't have rights to delete, it's as simple as that. My trials thru the command line where as root thx guys janbro Richard Lynch schrieb: > What you are doing wrong is ignoring the error messages MySQL is storing > for you... > > > On Mon, May 30, 2005 12:37 pm, janbro said: > >>Hi List, I don't know where else to look. I've got PHP 5.0.0 and MySQL >>4.1.3. (on Windwows XP with Apache 2.0.50) >> >>Here is my Code: the Query with the delete is not executed and I don't >>know why. If I copy it into the MySQL Command line like it is here, >>everything works fine. I have another example with a more simple delete >>which works (same syntax) >> >>If I replace the delete with the insert statement it works. >> >>What 'am I doing wrong here? >> >> >> >> >>>public function DeleteOldFails (){ >>> $conClas=$this->con(); >>> $con=$conClas->mysqlConnect (); >>> >>> $query = "DELETE FROM LoginTracker WHERE >>>(UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - UNIX_TIMESTAMP(DateAttack)) > >>>3600;"; >>>// $query ="INSERT INTO LoginTracker (IPAttack, User) VALUES >>>('127.0.0.1','user')"; >>> echo "$conDiesen Auf ERFOLG TESTEN! LÖSCHT ER WAS ER SOLL? >>>$query"; >>> print $con->query($query); > > > echo mysql_error(); > > >>> $con->query("OPTIMIZE TABLE LoginTracker "); >>> >>> $this->discon ($conClas, $con); >>> } >> >>thx >>janbro >> >>-- >>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] Code Check
What you are doing wrong is ignoring the error messages MySQL is storing for you... On Mon, May 30, 2005 12:37 pm, janbro said: > Hi List, I don't know where else to look. I've got PHP 5.0.0 and MySQL > 4.1.3. (on Windwows XP with Apache 2.0.50) > > Here is my Code: the Query with the delete is not executed and I don't > know why. If I copy it into the MySQL Command line like it is here, > everything works fine. I have another example with a more simple delete > which works (same syntax) > > If I replace the delete with the insert statement it works. > > What 'am I doing wrong here? > > > >> public function DeleteOldFails (){ >> $conClas=$this->con(); >> $con=$conClas->mysqlConnect (); >> >> $query = "DELETE FROM LoginTracker WHERE >> (UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - UNIX_TIMESTAMP(DateAttack)) > >> 3600;"; >> // $query ="INSERT INTO LoginTracker (IPAttack, User) VALUES >> ('127.0.0.1','user')"; >> echo "$conDiesen Auf ERFOLG TESTEN! LÖSCHT ER WAS ER SOLL? >> $query"; >> print $con->query($query); echo mysql_error(); >>$con->query("OPTIMIZE TABLE LoginTracker "); >> >> $this->discon ($conClas, $con); >> } > > thx > janbro > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code Check
janbro wrote: Hi List, I don't know where else to look. I've got PHP 5.0.0 and MySQL 4.1.3. (on Windwows XP with Apache 2.0.50) Here is my Code: the Query with the delete is not executed and I don't know why. If I copy it into the MySQL Command line like it is here, everything works fine. I have another example with a more simple delete which works (same syntax) If I replace the delete with the insert statement it works. What 'am I doing wrong here? public function DeleteOldFails (){ $conClas=$this->con(); $con=$conClas->mysqlConnect (); $query = "DELETE FROM LoginTracker WHERE (UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - UNIX_TIMESTAMP(DateAttack)) > 3600;"; // $query ="INSERT INTO LoginTracker (IPAttack, User) VALUES ('127.0.0.1','user')"; echo "$conDiesen Auf ERFOLG TESTEN! LÖSCHT ER WAS ER SOLL? $query"; print $con->query($query); $con->query("OPTIMIZE TABLE LoginTracker "); $this->discon ($conClas, $con); } thx janbro Have you checked that the two previous function calls are returning as expected? HTH, Mikey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Code Check
Hi List, I don't know where else to look. I've got PHP 5.0.0 and MySQL 4.1.3. (on Windwows XP with Apache 2.0.50) Here is my Code: the Query with the delete is not executed and I don't know why. If I copy it into the MySQL Command line like it is here, everything works fine. I have another example with a more simple delete which works (same syntax) If I replace the delete with the insert statement it works. What 'am I doing wrong here? > public function DeleteOldFails (){ > $conClas=$this->con(); > $con=$conClas->mysqlConnect (); > > $query = "DELETE FROM LoginTracker WHERE > (UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - UNIX_TIMESTAMP(DateAttack)) > 3600;"; > //$query ="INSERT INTO LoginTracker (IPAttack, User) VALUES > ('127.0.0.1','user')"; > echo "$conDiesen Auf ERFOLG TESTEN! LÖSCHT ER WAS ER SOLL? > $query"; > print $con->query($query); > $con->query("OPTIMIZE TABLE LoginTracker "); > > $this->discon ($conClas, $con); > } thx janbro -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code check please
From: "James Johnson" <[EMAIL PROTECTED]> > Can anyone see why this code isn't working > > $SID = $_SESSION['svUserID']; > $AdID = $_GET['AdID']; > > // get the campuses assigned > $qCampusID = "SELECT inst_id FROM ads_campuses WHERE ad_id = $AdID"; You say down below that this query only selects one row... > $CampusIDList = mysql_query($qCampusID, $CCB) or die(mysql_error()); > $row_CampusIDList = mysql_fetch_assoc($CampusIDList); and this mysql_fetch_assoc() call will return that one row into $row_CampusIDList. > //var_dump($row_CampusIDList); > > $tmp = array(); > while( $rowData = mysql_fetch_array( $CampusIDList )) { This while will never execute as there are no more rows to select. > //print("ROW Data $rowData"); > if(!in_array($rowData['inst_id'],$tmp)){ > $tmp[] = $rowData['inst_id']; > } > } > //var_dump($tmp); > $cidList = implode( ',', $tmp ); > //var_dump($cidList); > > If I do a var_dump($row_CampusIDList); I get a value, so I know there's data > to work with. But if I do a var_dump($tmp) and var_dump($cidList), they're > both empty. > > This particular value query only has 1 inst_id of 100. Other queries with > one value (99,45, etc) will work. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Code check please
Hmm, ok I took out the $row_CampusIDList = mysql_fetch_assoc($CampusIDList); and it works But how come? J -Original Message- From: James Johnson [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 17, 2003 9:17 AM To: [EMAIL PROTECTED] Subject: [PHP] Code check please Hi, Can anyone see why this code isn't working $SID = $_SESSION['svUserID']; $AdID = $_GET['AdID']; // get the campuses assigned $qCampusID = "SELECT inst_id FROM ads_campuses WHERE ad_id = $AdID"; $CampusIDList = mysql_query($qCampusID, $CCB) or die(mysql_error()); $row_CampusIDList = mysql_fetch_assoc($CampusIDList); //var_dump($row_CampusIDList); $tmp = array(); while( $rowData = mysql_fetch_array( $CampusIDList )) { //print("ROW Data $rowData"); if(!in_array($rowData['inst_id'],$tmp)){ $tmp[] = $rowData['inst_id']; } } //var_dump($tmp); $cidList = implode( ',', $tmp ); //var_dump($cidList); If I do a var_dump($row_CampusIDList); I get a value, so I know there's data to work with. But if I do a var_dump($tmp) and var_dump($cidList), they're both empty. This particular value query only has 1 inst_id of 100. Other queries with one value (99,45, etc) will work. Very strange... Thanks, James -- 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] Code check please
Hi, Can anyone see why this code isn't working $SID = $_SESSION['svUserID']; $AdID = $_GET['AdID']; // get the campuses assigned $qCampusID = "SELECT inst_id FROM ads_campuses WHERE ad_id = $AdID"; $CampusIDList = mysql_query($qCampusID, $CCB) or die(mysql_error()); $row_CampusIDList = mysql_fetch_assoc($CampusIDList); //var_dump($row_CampusIDList); $tmp = array(); while( $rowData = mysql_fetch_array( $CampusIDList )) { //print("ROW Data $rowData"); if(!in_array($rowData['inst_id'],$tmp)){ $tmp[] = $rowData['inst_id']; } } //var_dump($tmp); $cidList = implode( ',', $tmp ); //var_dump($cidList); If I do a var_dump($row_CampusIDList); I get a value, so I know there's data to work with. But if I do a var_dump($tmp) and var_dump($cidList), they're both empty. This particular value query only has 1 inst_id of 100. Other queries with one value (99,45, etc) will work. Very strange... Thanks, James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] code check
on 8/23/01 11:51 AM, Tom Malone at [EMAIL PROTECTED] wrote: > Sorry to bother you all with this, but I have no way to test this, as I have > no access to a Mac. Could you tell me if this little piece of code looks as > if it would work (detect whether someone's using the Mac OS)? ie 5.0 macos 9, powermac G3, i end up in the 'true' branch, but nothing happens to my font that i can tell... > > if (preg_match("/mac/i", "$HTTP_USER_AGENT") || preg_match("/macintosh/i", > "$HTTP_USER_AGENT") || preg_match("/ppc/i", "$HTTP_USER_AGENT") || > preg_match("/PowerPC/i", "$HTTP_USER_AGENT")): > $basefont = "Geneva"; > else: > $basefont = "Verdana, Helvetica, Serif"; > endif; > > It doesn't return an error, but that doesn't mean it works. I really > appreciate your help. TIA > > Tom Malone > Web Designer > http://www.tom-malone.com > -- mike cullerton -- PHP General 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] code check
Sorry to bother you all with this, but I have no way to test this, as I have no access to a Mac. Could you tell me if this little piece of code looks as if it would work (detect whether someone's using the Mac OS)? if (preg_match("/mac/i", "$HTTP_USER_AGENT") || preg_match("/macintosh/i", "$HTTP_USER_AGENT") || preg_match("/ppc/i", "$HTTP_USER_AGENT") || preg_match("/PowerPC/i", "$HTTP_USER_AGENT")): $basefont = "Geneva"; else: $basefont = "Verdana, Helvetica, Serif"; endif; It doesn't return an error, but that doesn't mean it works. I really appreciate your help. TIA Tom Malone Web Designer http://www.tom-malone.com -- PHP General 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] Code check please
Andreas Skarin wrote: > > I've tried to get this working for over an hour > now, and it still won't. I don't even get an error > message to help me find the problem so I was > hoping that someone could check my code for me. > > I'm fooling around with a basic form that is > supposed to send one's name, surname and e-mail > address to "receive.php". "receive.php" is then > supposed to take the information and add it to a > table called "tabell" in a database called > "databas", but it doesn't work. I think there > might be something wrong with my MySQL query. > > - - - - - - - - - - - FORM - - - - - - - - - - - - > - - > > > Förnamn: > size="25"> > Efternamn: > size="25"> > E-mailadress: > size="25"> > value="Log in"> > > > - - - - - - - - - - - - - - - - - - - - - - - - - > - - - > > - - - - - - - - - - - RECEIVE.PHP - - - - - - - - > - - - > > > // connection to MySQL > $connection = mysql_connect("localhost", > "username", "password"); > if (!$connection) { > echo ("Unable to connect to the database > server at this time." ); > exit(); > } > > //select database > if (! @mysql_select_db("databas") ) { > echo ("Unable to locate the database at > this time."); > exit(); > } > > // MySQL query > $sql = "INSERT INTO tabell SET" . > "fornamn ='$fornamn'," . > "efternamn='$efternamn'," . > "email='$email';"; > ?> Hello, and where is the mysql_query($sql) function call? Robert -- PHP General 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] Code check please
It just occurred to me that one thing that will kill a query is special query characters imbedded in your strings, like quotes (single or double). This can be resolved by the $resultstring = addslashes($sourcestring); this should escape special characters normally used to signal key components to the mysql query processor. of course when you select the column you need to run it thru; $resultstring = stripslashes($dbcolumnvalue); to get back your original value. good luck, Warren Vail -Original Message- From: Andreas Skarin [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 20, 2001 3:46 PM To: PHP General Subject: Re: [PHP] Code check please I'm sorry guys, neither of the snippets work. I must have screwed something else up too. Is there any way I can provoke an error message from your code examples below? If anyone manages to find out what's wrong, please tell me. I'm not giving up until I smash this bug :-) // Andreas > Rich Cavanaugh wrote: > > > try: > > > > $sql = "INSERT INTO tabell (fornamn, efternamn, email) values ('{$fornamn}', > > '{$efternamn}', '{$email}')"; > > Sebastian Wenleder wrote: > > > I'd use this SQL-query: > > > > $sql = "INSERT INTO tabell \ > > (fornamn,efternamn,email) \ > > VALUES(".$fornamn.", \ > > ".$efternamn.", ".$email.")"; -- Andreas Skarin Svenska Dream Theater-Sällskapet http://www.sdts.nu - mailto:[EMAIL PROTECTED] -- PHP General 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 General 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] Code check please
Andreas, I'm not sure about code that appears to be missing like an execute query function or checking the number of affected rows to make sure that the insert worked, but clearly your insert code is not properly formed. The query could also be impacted by whether the columns are defined with special attributes like DATE, etc. Assuming that all columns are defined as character strings the query should look like; $sql = "INSERT INTO tabell (fornamn, efternamn, email) " . "VALUES(\"$fornamn\", \"$efternamn\", \"$email\")"; I've found that I often have problems trying to use "single quotes" in sql queries so I avoid them. I notice that you also included a semi-colon in the query text, while this works when piping a file of queries into the mysql command, it does not work from a program. The semi-colon in a command stream into the mysql command actually signifies a point to stop and execute the preceding text as a query and after executing that query, continue on from the next character. hope you got it working, Warren Vail -Original Message- From: Andreas Skarin [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 20, 2001 9:00 AM To: PHP General Subject: [PHP] Code check please I've tried to get this working for over an hour now, and it still won't. I don't even get an error message to help me find the problem so I was hoping that someone could check my code for me. I'm fooling around with a basic form that is supposed to send one's name, surname and e-mail address to "receive.php". "receive.php" is then supposed to take the information and add it to a table called "tabell" in a database called "databas", but it doesn't work. I think there might be something wrong with my MySQL query. - - - - - - - - - - - FORM - - - - - - - - - - - - - - Förnamn: Efternamn: E-mailadress: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECEIVE.PHP - - - - - - - - - - - Unable to connect to the database server at this time." ); exit(); } //select database if (! @mysql_select_db("databas") ) { echo ("Unable to locate the database at this time."); exit(); } // MySQL query $sql = "INSERT INTO tabell SET" . "fornamn ='$fornamn'," . "efternamn='$efternamn'," . "email='$email';"; ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - Thanks in advance! // Andreas -- PHP General 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 General 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] Code check please
You want mysql_error(), call it somewhere after your query. echo mysql_error(); Regarding the query, the following should work just fine : $sql = "INSERT INTO tablefoo (a,b,c) VALUES ('$a','$b','$c')"; Be sure to add slashes sometime to your values beforehand. Anyway, mysql_error() is what you're wanting. http://www.php.net/manual/function.mysql-error.php regards, philip On Thu, 21 Jun 2001, Andreas Skarin wrote: > I'm sorry guys, neither of the snippets work. I must have screwed something else up > too. Is there any way I can provoke an error message from your code examples below? > If anyone manages to find out what's wrong, please tell me. I'm not giving up until > I smash this bug :-) > > // Andreas > > > Rich Cavanaugh wrote: > > > > > try: > > > > > > $sql = "INSERT INTO tabell (fornamn, efternamn, email) values ('{$fornamn}', > > > '{$efternamn}', '{$email}')"; > > > > Sebastian Wenleder wrote: > > > > > I'd use this SQL-query: > > > > > > $sql = "INSERT INTO tabell \ > > > (fornamn,efternamn,email) \ > > > VALUES(".$fornamn.", \ > > > ".$efternamn.", ".$email.")"; > > > > > -- > Andreas Skarin > Svenska Dream Theater-Sällskapet > http://www.sdts.nu - mailto:[EMAIL PROTECTED] > > > > -- > PHP General 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 General 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] Code check please
what about just $sql = "INSERT INTO tabell \ > > (fornamn,efternamn,email) \ > > VALUES("$fornamn", \ > > "$efternamn", "$email")"; ?? -Original Message- From: Andreas Skarin [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 21, 2001 8:46 AM To: PHP General Subject: Re: [PHP] Code check please I'm sorry guys, neither of the snippets work. I must have screwed something else up too. Is there any way I can provoke an error message from your code examples below? If anyone manages to find out what's wrong, please tell me. I'm not giving up until I smash this bug :-) // Andreas > Rich Cavanaugh wrote: > > > try: > > > > $sql = "INSERT INTO tabell (fornamn, efternamn, email) values ('{$fornamn}', > > '{$efternamn}', '{$email}')"; > > Sebastian Wenleder wrote: > > > I'd use this SQL-query: > > > > $sql = "INSERT INTO tabell \ > > (fornamn,efternamn,email) \ > > VALUES(".$fornamn.", \ > > ".$efternamn.", ".$email.")"; -- Andreas Skarin Svenska Dream Theater-Sällskapet http://www.sdts.nu - mailto:[EMAIL PROTECTED] -- PHP General 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] Code check please
> 2. Your SQL is a bit out of whack. The "SET" clause is used for >UPDATEs, not INSERTs. > >Instead, try: > >$sql = "INSERT INTO tabell (fornamn, efternamn, email) VALUES (" . > "'$fornamn', '$efternamn', '$email');"; MySQL actually lets you use SET for INSERTS, though. Jason -- PHP General 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] Code check please
I'm sorry guys, neither of the snippets work. I must have screwed something else up too. Is there any way I can provoke an error message from your code examples below? If anyone manages to find out what's wrong, please tell me. I'm not giving up until I smash this bug :-) // Andreas > Rich Cavanaugh wrote: > > > try: > > > > $sql = "INSERT INTO tabell (fornamn, efternamn, email) values ('{$fornamn}', > > '{$efternamn}', '{$email}')"; > > Sebastian Wenleder wrote: > > > I'd use this SQL-query: > > > > $sql = "INSERT INTO tabell \ > > (fornamn,efternamn,email) \ > > VALUES(".$fornamn.", \ > > ".$efternamn.", ".$email.")"; -- Andreas Skarin Svenska Dream Theater-Sällskapet http://www.sdts.nu - mailto:[EMAIL PROTECTED] -- PHP General 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] Code check please
UPDATE syntax for INSERT is allowed in MySQL, so that should not be the problem as far as you include all fields not having default value, timestamp type or auto_increment attribute in your statement. What's the error message if there is any? lenar ""Rich Cavanaugh"" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > You're using UPDATE syntax for your INSERT > > try: > > $sql = "INSERT INTO tabell (fornamn, efternamn, email) values ('{$fornamn}', > '{$efternamn}', '{$email}')"; > > Rich Cavanaugh > > -Original Message- > From: Andreas Skarin [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, June 20, 2001 12:00 PM > To: PHP General > Subject: [PHP] Code check please > > > I've tried to get this working for over an hour > now, and it still won't. I don't even get an error > message to help me find the problem so I was > hoping that someone could check my code for me. > > I'm fooling around with a basic form that is > supposed to send one's name, surname and e-mail > address to "receive.php". "receive.php" is then > supposed to take the information and add it to a > table called "tabell" in a database called > "databas", but it doesn't work. I think there > might be something wrong with my MySQL query. > > - - - - - - - - - - - FORM - - - - - - - - - - - - > - - > > > Förnamn: > size="25"> > Efternamn: > size="25"> > E-mailadress: > size="25"> > value="Log in"> > > > - - - - - - - - - - - - - - - - - - - - - - - - - > - - - > > - - - - - - - - - - - RECEIVE.PHP - - - - - - - - > - - - > > > // connection to MySQL > $connection = mysql_connect("localhost", > "username", "password"); > if (!$connection) { > echo ("Unable to connect to the database > server at this time." ); > exit(); > } > > //select database > if (! @mysql_select_db("databas") ) { > echo ("Unable to locate the database at > this time."); > exit(); > } > > // MySQL query > $sql = "INSERT INTO tabell SET" . > "fornamn ='$fornamn'," . > "efternamn='$efternamn'," . > "email='$email';"; > ?> > > - - - - - - - - - - - - - - - - - - - - - - - - - > - - - > > Thanks in advance! > > // Andreas > > > -- > PHP General 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 General 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 General 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] Code check please
At 18:00 Uhr +0200 20.06.2001, Andreas Skarin wrote: >I've tried to get this working for over an hour >now, and it still won't. I don't even get an error >message to help me find the problem so I was >hoping that someone could check my code for me. [snip] >$sql = "INSERT INTO tabell SET" . > "fornamn ='$fornamn'," . > "efternamn='$efternamn'," . > "email='$email';"; > Hi Andreas I'd use this SQL-query: $sql = "INSERT INTO tabell \ (fornamn,efternamn,email) \ VALUES(".$fornamn.", \ ".$efternamn.", ".$email.")"; Hope it works for you! Best, Sebastian -- PHP General 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] Code check please
You're using UPDATE syntax for your INSERT try: $sql = "INSERT INTO tabell (fornamn, efternamn, email) values ('{$fornamn}', '{$efternamn}', '{$email}')"; Rich Cavanaugh -Original Message- From: Andreas Skarin [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 20, 2001 12:00 PM To: PHP General Subject: [PHP] Code check please I've tried to get this working for over an hour now, and it still won't. I don't even get an error message to help me find the problem so I was hoping that someone could check my code for me. I'm fooling around with a basic form that is supposed to send one's name, surname and e-mail address to "receive.php". "receive.php" is then supposed to take the information and add it to a table called "tabell" in a database called "databas", but it doesn't work. I think there might be something wrong with my MySQL query. - - - - - - - - - - - FORM - - - - - - - - - - - - - - Förnamn: Efternamn: E-mailadress: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECEIVE.PHP - - - - - - - - - - - Unable to connect to the database server at this time." ); exit(); } //select database if (! @mysql_select_db("databas") ) { echo ("Unable to locate the database at this time."); exit(); } // MySQL query $sql = "INSERT INTO tabell SET" . "fornamn ='$fornamn'," . "efternamn='$efternamn'," . "email='$email';"; ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - Thanks in advance! // Andreas -- PHP General 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 General 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] Code check please
Your code is [mostly] fine, except for two things: 1. Although you connected to your database with mysql_connect() and mysql_select_db(), you didn't do anything with connection. Try using mysql_query() to send a query to the db, i.e. mysql_query($sql). 2. Your SQL is a bit out of whack. The "SET" clause is used for UPDATEs, not INSERTs. Instead, try: $sql = "INSERT INTO tabell (fornamn, efternamn, email) VALUES (" . "'$fornamn', '$efternamn', '$email');"; Hope that works. J "Andreas Skarin" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I've tried to get this working for over an hour > now, and it still won't. I don't even get an error > message to help me find the problem so I was > hoping that someone could check my code for me. > > I'm fooling around with a basic form that is > supposed to send one's name, surname and e-mail > address to "receive.php". "receive.php" is then > supposed to take the information and add it to a > table called "tabell" in a database called > "databas", but it doesn't work. I think there > might be something wrong with my MySQL query. > > - - - - - - - - - - - FORM - - - - - - - - - - - - > - - > > > Förnamn: > size="25"> > Efternamn: > size="25"> > E-mailadress: > size="25"> > value="Log in"> > > > - - - - - - - - - - - - - - - - - - - - - - - - - > - - - > > - - - - - - - - - - - RECEIVE.PHP - - - - - - - - > - - - > > > // connection to MySQL > $connection = mysql_connect("localhost", > "username", "password"); > if (!$connection) { > echo ("Unable to connect to the database > server at this time." ); > exit(); > } > > //select database > if (! @mysql_select_db("databas") ) { > echo ("Unable to locate the database at > this time."); > exit(); > } > > // MySQL query > $sql = "INSERT INTO tabell SET" . > "fornamn ='$fornamn'," . > "efternamn='$efternamn'," . > "email='$email';"; > ?> > > - - - - - - - - - - - - - - - - - - - - - - - - - > - - - > > Thanks in advance! > > // Andreas > > > -- > PHP General 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 General 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] Code check please
I've tried to get this working for over an hour now, and it still won't. I don't even get an error message to help me find the problem so I was hoping that someone could check my code for me. I'm fooling around with a basic form that is supposed to send one's name, surname and e-mail address to "receive.php". "receive.php" is then supposed to take the information and add it to a table called "tabell" in a database called "databas", but it doesn't work. I think there might be something wrong with my MySQL query. - - - - - - - - - - - FORM - - - - - - - - - - - - - - Förnamn: Efternamn: E-mailadress: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RECEIVE.PHP - - - - - - - - - - - Unable to connect to the database server at this time." ); exit(); } //select database if (! @mysql_select_db("databas") ) { echo ("Unable to locate the database at this time."); exit(); } // MySQL query $sql = "INSERT INTO tabell SET" . "fornamn ='$fornamn'," . "efternamn='$efternamn'," . "email='$email';"; ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - Thanks in advance! // Andreas -- PHP General 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]