Home forums Chart Support Passing Form Variables to SQL

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #30406

    Hello,

    I am passing variables to my CanvasJS chart PHP from a web form

    This SQL works

    $handle = $link->prepare(‘select ext_rev as x, discount as y from mysql.ne_nj_tbl where pnl like \’Commercial NE Majors%\’ and manuf like \’CISCO%\”);

    This SQL fails

    $handle = $link->prepare(‘select ext_rev as x, discount as y from mysql.ne_nj_tbl where pnl like \’$pandl%\’ and manuf like \’$manuf_var%\”);

    I have used that SQL successfully in another PHP script but not with CanvasJS. Any ideas? TIA.

    #30418

    @dennisfaucher,

    There seems to be an issue with the MySQL query which you are performing.

    If you are unable to resolve the issue, kindly create a sample project reproducing the issue you are facing and share it with us over Google-Drive or Onedrive along with the sample database so that we run the code locally, understand the scenario better and help you out?


    Shashi Ranjan
    Team CanvasJS

    #30420

    @Shashi, thank you.

    The data fields are not important, it is passing web form variables to the SQL statement that I need help with.

    The PHP web form I am using is here: https://www.dropbox.com/s/7w2d7gy6nxaolex/inn_scatter_disc_entry.php?dl=0
    The CanvasJS PHP with the SQL statement is here: https://www.dropbox.com/s/t1vhw82rfl947nr/inn_scatter_disc.php?dl=0

    Here is an example of working PHP passing a web form to a SQL statement:

    PHP web form: https://www.dropbox.com/s/et2p8nvft9e38y9/detail_entry.php?dl=0
    Tabular result based on SQL: https://www.dropbox.com/s/r87ecj679ctejq4/detail_mysql.php?dl=0

    Thank you.

    #30495

    @dennisfaucher,

    Can you kindly create a working sample project reproducing the issue you are facing and share it with us over Google-Drive or Onedrive with the sample database and PHP files so that we can run the code locally, understand the scenario better and help you out?


    Shashi Ranjan
    Team CanvasJS

    #30562

    Fixed it. Yay.

    $pandl = $_POST[“pl”];
    $manuf_var = $_POST[“oem”];

    $sql_var=”select ext_rev as x, discount as y, customer as z, manuf as w from innovation.ne_nj_tbl where pnl like ‘$pandl%’ and manuf like ‘$manuf_var%'”;

    $handle = $link->prepare($sql_var);

    #30609

    @dennisfaucher,

    Glad that you figured it out :)


    Shashi Ranjan
    Team CanvasJS

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.