Jump to content

[SOLVED] Printing double quotes from database


neridaj

Recommended Posts

Hey,

 

I need to extract some width and height dimensions from a database that include double quotes i.e., 25" x 35". I can't figure out how to escape the quotes and print them to the page concatenated with other data. Here is the code I'm trying to use:

 

/*

<?php

 

include( 'dbinfo.php' );

$conn = mysql_connect( $dbhost, $dbuser, $dbpass );

mysql_select_db($dbname);

$sql = 'select painting_id, painting_title, painting_year, painting_details, painting_dimensions, painting_pixel_height, painting_status from paintings where painting_year = 2007';

$demoResult = mysql_query( $sql );

while ( $demoRow = mysql_fetch_row( $demoResult ) ) {

$id = $demoRow[0];

$title = $demoRow[1];

$year = $demoRow[2];

$details = $demoRow[3];

$dimensions = $demoRow[4];

$height = $demoRow[5];

$status = $demoRow[6];

$vartitle = str_replace(" ", "_", $title);

$vartitle = strtolower($vartitle);

$class = "floatright";

if($id % 2 != 0) {

$class = "";

}

 

$rndtitle = 'select painting_title from paintings where painting_year = 2007 order by rand() limit 1;';

$rndimg = mysql_query( $rndtitle );

$rndimg = mysql_fetch_array( $rndimg );

$rndimgtitle = $rndimg['painting_title'];

$rndimgtitle = strtolower($rndimgtitle);

$rndimgtitle = str_replace(" ", "_", $rndimgtitle);

$vardimensions = str_replace('"', '\"', $dimensions);

$caption = $title . ', ' . $year . '<br />' . $details .'<br />' . $vardimensions . '<br />' . $status;

 

echo '<a class="' . $class . '" href="javascript:;" onclick="document.thumblarge.src=\'images/' . $vartitle . '_sdw.jpg\'; document.thumblarge.height=\'' . $height . '\'; document.getElementById(\'caption\').innerHTML=\'' . $caption . '\';" onmouseout="MM_swapImgRestore();" onmouseover="MM_swapImage(\'' . $vartitle . '_off\',\'\',\'thumbs/' . $vartitle . '_on.jpg\',1);"><img name="' . $vartitle . '_off" src="thumbs/' . $vartitle . '_off.jpg" width="100" height="100" border="0" id="' . $vartitle . '_off" alt="" /></a>';

}echo $caption;

mysql_close ($conn);

 

?>

*/

 

Would it make more sense to leave the quotes out of the column and concatenate them to the data afterwards?

 

Thanks,

 

Jason

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.