A href link using new server-side script for PHP and MySQL

A href link using new server-side script for PHP and MySQL

enigmaitenigmait Posts: 3Questions: 0Answers: 0
edited August 2010 in General
Hi,

I'm having a few problems with the output line. I'm trying to link to a page to display the data from a particular ID. I think i'm not escaping $sIndexColumn properly.

[code]$sOutput .= '"'."".str_replace('"', '\"', $aRow[ $aColumns[$i] ]).''.'",';[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    How about:

    [code]
    $sOutput .= '"'.str_replace( '"', '\"', ''.$aRow[$aColumns[$i]].'' ).'",';
    [/code]
    Allan
  • enigmaitenigmait Posts: 3Questions: 0Answers: 0
    Hi,

    Thanks for the input. That sort of worked, but all it did was output the variable ID so now index.php?ID=ID.

    This is my complete code:

    [code]
    $aColumns = array('id','reference','date','name','company');

    $sTable = "report";
    $sTable2 = "company";
    $sTable3 = "users";

    $gaSql['user'] = "";
    $gaSql['password'] = "";
    $gaSql['db'] = "";
    $gaSql['server'] = "";

    $gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
    die( 'Could not open connection to server' );

    mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
    die( 'Could not select database '. $gaSql['db'] );

    $sLimit = "";
    if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
    {
    $sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
    mysql_real_escape_string( $_GET['iDisplayLength'] );
    }

    if ( isset( $_GET['iSortCol_0'] ) )
    {
    $sOrder = "ORDER BY ";
    for ( $i=0 ; $i
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    What about just using $aRow['id'] where you want the ID to be?

    Allan
  • enigmaitenigmait Posts: 3Questions: 0Answers: 0
    Thank you, that worked. Not sure why I didn't try that before.
This discussion has been closed.