Forums

PHP

This topic is locked

phakt form and ini question

Posted 20 Jan 2002 13:02:55
1
has voted
20 Jan 2002 13:02:55 stefano panusa posted:
Hello all, I did try to search out this problem, but here I am.

First off, I have an undefined variables problem with unchecked radio buttons when a form is submitted. Now, I thought from reading the forum that it might be my php.ini file, however, mine seems a little sparse compared to what everyone else has.. here it is:

; php.ini for PEAR tests
include_path=..
[mail function]
SMTP= localhost ; for Win32 only
sendmail_from= ; for Win32 only
upload_tmp_dir = C:\PHP\uploadtemp ; temporary directory for HTTP uploaded files (will use system default if not specified)
[Session]
session.save_path= C:\PHP\sessiondata ; argument passed to save_handler
[PHP]
error_reporting= E_ALL; display all errors, warnings and notices

Now, if I add the lines about magic quotes and change the error reporting, instead of undefined variables errors, I get:

You have an error in your SQL syntax near '20) values ('','','','','','',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'',NULL,NU' at line 1

Which is an empty form, the '' fields are text, the rest are radio buttons.

And I have set my mysql table to accept null values. And it all does work, if I input text in into the fields, and check the radio buttons.

Oh, and I should mention that I want to allow the user to leave some radio buttons unchecked completely.

Thanks for any help,
Stefano

Replies

Replied 20 Jan 2002 13:33:11
20 Jan 2002 13:33:11 chief monkey replied:
Have you tried changing the error reporting to
error_reporting = E_ALL & ~E_NOTICE

George

Everybody has got to be somewhere
Replied 20 Jan 2002 21:33:36
20 Jan 2002 21:33:36 stefano panusa replied:
I just tried that, and I get the aforementioned sql error.

Cheers,
Stefano
Replied 20 Jan 2002 22:17:42
20 Jan 2002 22:17:42 Tim Green replied:
Are you using the right PHP.ini ?

The reason I ask this question is that the PHP.ini is a pretty standard file, and it should be anything but sparse.

Sometimes though, there can be a bit of confusion as some distributions create 2 PHP.ini files in 2 separate places. One of them is relevant, and the other isn't.

If the entries you have posted are your *complete* PHP.ini, then you are using the wrong file. The location of the true PHP.ini on a Windows system is in the Windows directory.

If you're working on a file in your c:\PHP directory, then it is the wrong one.

From the initial quote too, there is a bit of a clue:-

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
; php.ini for PEAR tests
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

This tells me that these are the settings that should be changed in your PHP.ini for the PEAR libraries to work.

Anyway, I hope the above helps.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 21 Jan 2002 01:20:50
21 Jan 2002 01:20:50 stefano panusa replied:
I just did a system search for php.ini and the only one I have is in my winnt directory, and that is the one I've been working with. And if I alter it, I do get different 'reactions' from my scripts, so I think the php engine must be using it as well. Would it be useful for me to just copy and past someone elses working version and tweak it to my system? (ie. my winnt is on F<img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> or should i reinstall php altogether?

Cheers,
Stefano
Replied 21 Jan 2002 10:18:38
21 Jan 2002 10:18:38 stefano panusa replied:
Ok, I just installed the manual version of PHP and am using the exstensive php.ini that came with that.

Now, my only error is:

You have an error in your SQL syntax near '20) values ('','','','','','',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'',NULL,NU' at line 1

Which is what I was having before.

Cheers,
Stefano
Replied 21 Jan 2002 14:37:18
21 Jan 2002 14:37:18 Tim Green replied:
Could you post the relevant lines from your page, so we can see the SQL that you're using...?

Cheers

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 22 Jan 2002 00:16:10
22 Jan 2002 00:16:10 stefano panusa replied:
Ok, you asked for it, this is the code that the phakt insert record sb created (I would echo the sql statement, but I don't which one to do, all attempts have produced the above mentioned error):

&lt;?php


// Copyright (c) Interakt Online 2001
// www.interakt.ro/

require("./adodb/adodb.inc.php";
require("./Connections/connConnect.php";
?&gt;&lt;?php
// *** Edit Operations: declare Tables
$MM_editAction = $PHP_SELF;
if ($QUERY_STRING) {
$MM_editAction = $MM_editAction . "?" . $QUERY_STRING;
}
$MM_abortEdit = 0;
$MM_editQuery = "";
?&gt;&lt;?php
// *** Insert Record: set Variables

if (isset($MM_insert)){

// $MM_editConnection = MM_connConnect_STRING;
$MM_editTable = "users";
$MM_editRedirectUrl = "";
$MM_fieldsStr = "fname|value|lname|value|position|value|company|value|phone|value|email|value|tips1a|value|tips1b|value|tips1c|value|tips1d|value|tips1e|value|tips1f|value|tips1g|value|tips1h|value|tips1i|value|arts1a|value|arts1b|value|arts1c|value|arts1d|value|arts1e|value|arts1f|value|arts1g|value|arts1h|value|grass1a|value|grass1b|value|grass1c|value|grass1d|value|grass1e|value|grass1f|value|grass1g|value|grass1h|value|2a|value|2b|value|2c|value|2d|value|2e|value|2f|value|3a|value|3b|value|3c|value|4a|value|4b|value|4c|value|5a|value|5b|value|5c|value|6a|value|6b|value|6c|value|7a|value|7b|value|7c|value|7d|value|7e|value|8a|value|8b|value|8c|value|8d|value|8e|value|8f|value|8g|value|9a|value|9b|value|10a|value|10b|value|10c|value|11a|value|11b|value|12a|value|12b|value|12c|value|12d|value|13a|value|13b|value|13c|value|13d|value|13e|value|14a|value|14b|value|14c|value|15a|value|15b|value|16a|value|16b|value|17a|value|17b|value|17c|value|17d|value|18a|value|18b|value|18c|value|18d|value|18e|value|18f|value|18g|value|18h|value|18i|value|18j|value|18k|value|19a|value|19b|value|20|value";
$MM_columnsStr = "fname|',none,''|lname|',none,''|position|',none,''|company|',none,''|phone|',none,''|email|',none,''|tips1a|none,none,NULL|tips1b|none,none,NULL|tips1c|none,none,NULL|tips1d|none,none,NULL|tips1e|none,none,NULL|tips1f|none,none,NULL|tips1g|none,none,NULL|tips1h|none,none,NULL|tips1i|',none,''|arts1a|none,none,NULL|arts1b|none,none,NULL|arts1c|none,none,NULL|arts1d|none,none,NULL|arts1e|none,none,NULL|arts1f|none,none,NULL|arts1g|none,none,NULL|arts1h|',none,''|grass1a|none,none,NULL|grass1b|none,none,NULL|grass1c|none,none,NULL|grass1d|none,none,NULL|grass1e|none,none,NULL|grass1f|none,none,NULL|grass1g|none,none,NULL|grass1h|',none,''|2a|none,none,NULL|2b|none,none,NULL|2c|none,none,NULL|2d|none,none,NULL|2e|none,none,NULL|2f|',none,''|3a|none,none,NULL|3b|none,none,NULL|3c|',none,''|4a|none,none,NULL|4b|none,none,NULL|4c|none,none,NULL|5a|none,none,NULL|5b|none,none,NULL|5c|none,none,NULL|6a|none,none,NULL|6b|none,none,NULL|6c|none,none,NULL|7a|none,none,NULL|7b|none,none,NULL|7c|none,none,NULL|7d|none,none,NULL|7e|none,none,NULL|8a|none,none,NULL|8b|none,none,NULL|8c|none,none,NULL|8d|none,none,NULL|8e|none,none,NULL|8f|none,none,NULL|8g|none,none,NULL|9a|none,none,NULL|9b|none,none,NULL|10a|none,none,NULL|10b|none,none,NULL|10c|',none,''|11a|none,none,NULL|11b|none,none,NULL|12a|none,none,NULL|12b|none,none,NULL|12c|none,none,NULL|12d|',none,''|13a|none,none,NULL|13b|none,none,NULL|13c|none,none,NULL|13d|none,none,NULL|13e|',none,''|14a|none,none,NULL|14b|none,none,NULL|14c|none,none,NULL|15a|none,none,NULL|15b|none,none,NULL|16a|none,none,NULL|16b|none,none,NULL|17a|none,none,NULL|17b|none,none,NULL|17c|none,none,NULL|17d|',none,''|18a|none,none,NULL|18b|none,none,NULL|18c|none,none,NULL|18d|none,none,NULL|18e|none,none,NULL|18f|none,none,NULL|18g|none,none,NULL|18h|none,none,NULL|18i|none,none,NULL|18j|none,none,NULL|18k|none,none,NULL|19a|none,none,NULL|19b|none,none,NULL|20|',none,''";

// create the $MM_fields and $MM_columns arrays
$MM_fields = explode("|", $MM_fieldsStr);
$MM_columns = explode("|", $MM_columnsStr);

// set the form values
for ($i=0; $i+1 &lt; sizeof($MM_fields); ($i=$i+2)) {
$MM_fields[$i+1] = $$MM_fields[$i];
}

// append the query string to the redirect URL
if ($MM_editRedirectUrl && $QUERY_STRING && (strlen($QUERY_STRING) &gt; 0)) {
$MM_editRedirectUrl .= ((strpos($MM_editRedirectUrl, '?') == false)?"?":"&" . $QUERY_STRING;
}
}
?&gt;&lt;?php
// *** Insert Record: construct a sql insert statement and execute it
if (isset($MM_insert)) {
// create the sql insert statement
$MM_tableValues = "";
$MM_dbValues = "";
for ( $i=0; $i+1 &lt; sizeof($MM_fields); ($i=$i+2)) {
$formVal = $MM_fields[$i+1];
$MM_typesArray = explode(",", $MM_columns[$i+1]);
$delim = $MM_typesArray[0];
if($delim=="none" $delim="";
$altVal = $MM_typesArray[1];
if($altVal=="none" $altVal="";
$emptyVal = $MM_typesArray[2];
if($emptyVal=="none" $emptyVal="";
if ($formVal == "" || !isset($formVal)) {
$formVal = $emptyVal;
}
else {
if ($altVal != "" {
$formVal = $altVal;
}
else if ($delim == "'" { // escape quotes
$formVal = $delim . $formVal . $delim;
//$formVal = "'" . str_replace("'","\'",$formVal) . "'";
}
else {
$formVal = $delim . $formVal . $delim;
}
}
if ($i == 0) {
$MM_tableValues = $MM_tableValues . $MM_columns[$i];
$MM_dbValues = $MM_dbValues . $formVal;
}
else {
$MM_tableValues = $MM_tableValues . "," . $MM_columns[$i];
$MM_dbValues = $MM_dbValues . "," . $formVal;
}
}
$MM_editQuery = "insert into " . $MM_editTable . " (" . $MM_tableValues . " values (" . $MM_dbValues . "";
if ($MM_abortEdit!=1) {
// execute the insert
$queryrs = $connConnect-&gt;Execute($MM_editQuery) or DIE($connConnect-&gt;ErrorMsg());
if ($MM_editRedirectUrl) {
header ("Location: $MM_editRedirectUrl";
}
}
}
?&gt;&lt;?php
$Recordset1=$connConnect-&gt;Execute("SELECT * FROM users" or DIE($connConnect-&gt;ErrorMsg());
$Recordset1_numRows=0;
$Recordset1__totalRows=$Recordset1-&gt;RecordCount();
?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Survey&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;link rel="stylesheet" href="menu.css" type="text/css"&gt;
&lt;/head&gt;
&lt;body bgcolor="#FFFFFF" text="#000000"&gt;
&lt;form ACTION="&lt;?php echo $MM_editAction?&gt;" METHOD="POST" name="form1"&gt;
Replied 22 Jan 2002 01:38:24
22 Jan 2002 01:38:24 Tim Green replied:
Well, I must admit that I've looked through the code, and because of the sheer number of Form Fields in there,
I can't make head nor tail of it all...... I mean, there are 102 form fields in there!

Out of interest, do you get this same error with a form that has only a few fields in it?
I'm just wondering if it could be an issue with the parse routine that sorts all the SQL out etc....


Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>

Edited by - rawveg on 22 Jan 2002 01:39:09
Replied 22 Jan 2002 05:16:22
22 Jan 2002 05:16:22 stefano panusa replied:
Yes, I just tried it with alot fewer records and it worked fine. So there must be a limit to how many variables can be passed at one time. Once I'm done this projece maybe I will see if I can find out what it is. For now, I guess the solution is to insert the records, and redirect to another page of questions, insert and redirect again.
Replied 13 Feb 2003 12:37:13
13 Feb 2003 12:37:13 J D replied:
I have a similar problem! I am getting the following error message when either inserting or updating using the standard phakt code. The interesting thing is it doesn't always happen and I think it has to do with commas or aphostrophes in the text being inserted into mysql:

You have an error in your SQL syntax near 's 4-star rating assures you that each of our hotels 110 rooms offers all the com' at line 1

The text I'm trying to insert is:

Low Wood's 4-star rating assures you that each of our hotels 110 rooms offers all the comfort and luxury for a memorable stay. As Low Wood is in the heart of the lake district, you're also in the ideal place to discover the whole of this timeless lakeland landscape.

When I pull out the apostrophes and commas it works fine.

The code in the page is listed below:

// $MM_editConnection = $MM_mysqlbw1_STRING;
$MM_editTable = "news";
$MM_editColumn = "NewsID";
$MM_recordId = "" . $MM_recordId . "";
$MM_editRedirectUrl = "news_update_master.php";
$MM_fieldsStr = "Title|value|text1|value|link|value|ImageAlign|value|text5|value|dateupdated|value|username|value|Title|value|ImageAlign|value|text5|value";
$MM_columnsStr = "Title|',none,''|Text1|',none,''|LinkUrl|',none,''|ImageAlign|',none,''|Text5|',none,''|DateUpdated|',none,''|User|',none,''|Title|',none,''|ImageAlign|',none,''|Text5|',none,''";

// create the $MM_fields and $MM_columns arrays
$MM_fields = Explode("|", $MM_fieldsStr);
$MM_columns = Explode("|", $MM_columnsStr);


Any help with this would be much appreciated!
Replied 13 Feb 2003 15:28:56
13 Feb 2003 15:28:56 Brent Colflesh replied:
Dear Eugeneelh,
Do you have magic_quotes on or off in your .ini?

Regards,
Brent

Reply to this topic