mySQL help
- Started
- Last post
- 14 Responses
- frankosonik
I'm stuck. I've got a syntax error that I have no idea about. Because of security issues I can't post the stuff here. Help me find the answer and I'll send you an Amazon gift cert for $20.
AIM: frankosonik
- alexkxs0
Otsego valley UP noRTH? 8)
- unfittoprint0
hmmm, try to use addslashes to your POST variables___ that might be the problem.
tip: if that's php 4.1 or ++, use $_POST isntead of §HTTP_POST_VARS
- moth0
Hmm. First thing I notice is that id_number has a length of 1.
That wont work beyond 9 entries...
I'd use mediumint.
?
But what do I know?!!!
- moth0
mediumint and no length....
- Shimmer0
Remove the semicolon near the end of line 2. Shouldn't be between quotes. Only at the end of a line.
WHERE id_number=$id",
- frankosonik0
I've implemented a couple of your suggestions, I still get the same error:
http://www.finishbyfriday.com/sq…
I'm listing the "id_number" in the data structure with one digit because there will only be 7 rows, one for each day of the week.
- frankosonik0
Unfit: above the code in the link, I'm adding slashes:
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "decimal":
$theValue = ($theValue != "") ? floatval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
- enobrev0
hey, right after that $updateSQL = ... line, do a
echo $updateSQL;
and post the full variable output.
That error you're getting is generally due to a lacke of quote or a misplaced comma.
- enobrev0
also, you're using things like 'tintext' and 'year' as your data types, which are valid mysql data types but your GetSQLValueString function doesn't cover for them.
you should have that switch statement either have a default case which treats it like a string (quotes it), or add those extra cases (both would probably be best).
- enobrev0
oh... one more thing in response to unfit's post. a mediumint is fine for an id field, but it depends on how many records you expect to keep.
A mediumint has a maximum length of 8, which means you could have id's that get up to 99,999,999, on a field as mediumint(8) which is just under a million. That's quite a lot of wiggle room with db rows.
- frankosonik0
thanks enobrev, let me try your suggestions.
- frankosonik0
Bravo, Enobrev.
The GetSQLValueString suggestion was the trick. Thanks to all who helped -- Enobrev, send me your info and I'll send out your Amazon gift cert right away.
- enobrev0
no need... thanks though, frank.