GarryJones wrote:
> I am accessing a Mysql database with php scripting
>
> This first version works ok
> $cykdag_collers='SELECT * FROM cykdag WHERE cykdag_num = 79';
> $cykdagers_tbd=mysql_query($cykdag_collers);
> echo mysql_error();
>
> But 79 is a variable so I tried this
>
> $cykdag_collers='SELECT * FROM cykdag WHERE cykdag_num = $cykdag_ers';
> $cykdagers_tbd=mysql_query($cykdag_collers);
> echo mysql_error();
>
> And got this error
> Unknown column '$cykdag_ers' in 'where clause'
>
> So I tried this
> $cykdag_collers="SELECT * FROM cykdag WHERE cykdag_num = $cykdag_ers";
> $cykdagers_tbd=mysql_query($cykdag_collers);
> ......which seems to work ok as far as I can tell. But when adding
> "echo mysql_error()" to the same code
> like this
> $cykdag_collers="SELECT * FROM cykdag WHERE cykdag_num = $cykdag_ers";
> $cykdagers_tbd=mysql_query($cykdag_collers);
> echo mysql_error();
>
> it reports this error...
> You have an error in your SQL syntax; check the manual that
> corresponds to your MySQL server version for the right syntax to use
> near '' at line 1
>
> Can I ignore this? How can I do this without getting an error? The
> error will confuse my users but I want to use echo mysql_error() in
> case it reports other errors.
>
> Any apreciated
>
> Garry Jones
> Sweden
>
Always check the result of a mysql command. If it is false, THEN check
the error message. I don't believe it is guaranteed to be valid if no
error is returned.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================