Re: Multiple <a> Tags, Filled With MySQL DB data with PHP [message #179246 is a reply to message #179241] |
Tue, 25 September 2012 23:19 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma:
|
Senior Member |
|
|
On Tue, 25 Sep 2012 22:12:43 +0200, Luuk wrote:
> On 25-09-2012 21:58, tom(dot)rankin51(at)googlemail(dot)com wrote:
>> I'm not too sure how to debug correctly following these instructions.
>> I can place the code at the beginning and end of my page, but I am
>> getting a syntax error when typing $result = mysqli->query($sql);
>>
>>> <?php $sql = ".......";
>>> $result = mysqli->query( $sql );
>
>>> $debugtxt .= "sql: {$sql}\n";
>
> or, that last one could be:
> echo "SQL: {$sql}\n";
>
> it should echo the query to the output......
Yeah, but when I'm trying to debug code generating a web page, I stick
all the debugging output in a <pre> element at the end of the page, if I
don't get the pre element output the problem is invariably identified in
the server error log.
To the OP - sorry, you're not using mysqli .... replace "$result = mysqli-
> exec( $sql );" with whatever code you're using to make your database
call, maybe the "mysql_query" call.
Change this php:
$visuals_query=mysql_query("SELECT id, imagelink, comment, picdate, rel
FROM PictureMedia ORDER BY picdate DESC");
To:
<?php
$sql = "SELECT id, imagelink, comment, picdate, rel FROM PictureMedia
ORDER BY picdate DESC";
$visuals_query=mysql_query( $sql );
$debug = "sql: " $sql . "\nresult: " . var_dump( $visuals_query ) . "\n";
if ( $visuals_query == false )
$debug .= "sql error: " . mysql_error() . "\n";
?>
and then use the
<?php echo "<php>{$debug}</pre>"; ?>
to show the actual query, the query result set (warning, can be large)
and any sql error messages.
Rgds
Denis McMahon
|
|
|