0

I have created a simple 10 field or so mysql database. I have verified connectivity to the database via test php app and am using example code from JqWidgets to load said data using a connect.php and data.php file finally into index.php where a JqWidgets grid exists. I am receiving an error and have checked my syntax, checked the web for similar issues, searched based on the error I am receiving and I am still unable to work through the problem - so I thought I would submit my first post here. :) Thanks for any help that might be provided.

db name: texoma00_wardialers table name: table1

Code to follow for data.php which is where I am encountering the error. Note that I am only retrieving 2 fields below as I was trying to eliminate all possibilities of what was causing the error..

The error I see:

[12-Jul-2018 09:19:04 America/New_York] PHP Parse error: syntax error, unexpected ']', expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home/texoma00/wardialers.org/data.php on line 24

My Code:

<?php
#Include the connect.php file
include ('connect.php');
// Connect to the database
$mysqli = new mysqli($hostname, $username, $password, $database);
/* check connection */
if ( mysqli_connect_errno())
    {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
    }
// get data and store in a json array
$from = 0;
$to = 30;
$query = 'SELECT * FROM Table1';
$result = $mysqli->prepare($query);
$result->bind_param('ii', $from, $to);
$result->execute();
/* bind result variables */
$result->bind_result($GrpAffil, $BBSAffil);
/* fetch values */
while ($result->fetch())
    {
    $table1[] = array(
        'GrpAffil' => $GrpAffil,
        'BBSAffil' => $BBSAffil
    );
    }
echo json_encode($table1);
/* close statement */
$result->close();
/* close connection */
$mysqli->close();
?>

Thank you for any help you might provide... Flames are fine - I'm a noob. But I have definitely done some legwork trying to find the answer myself.

  • 4
    Never, ever, use curly quotes in coding ;) – IncredibleHat Jul 12 '18 at 16:38
  • `$query = "SELECT * FROM Table1”;` try to correct the double curly quote in the final line with `"` – kip Jul 12 '18 at 16:38
  • It looks like the double bracket thing is the problem - but just so I am positive, you are saying use single quote ' rather than " .. ? – lucidphreak Jul 12 '18 at 16:42
  • Look at the color coding in your post, is a good hint as to what went horribly wrong. You tried to close a double-quote string with a curly double-quote character. This... breaks the code. – IncredibleHat Jul 12 '18 at 16:43
  • It's odd that you're binding parameters when there's no parameters in your query. – tadman Jul 12 '18 at 16:57
  • So you went and edited your question to remove the odd character that was breaking your code and causing the parse error ....... but then didn't say if that fixed your issue or not? This question is no longer valid. – IncredibleHat Jul 12 '18 at 17:09
  • dont use $table1[], so use $table1 in line no. 24 – Boopathi D Jul 12 '18 at 17:13
  • You all helped me - but the underlying problem was me not realizing that table names were case sensitive... I was using "table1" but in MySQL it was TABLE1... I am good now. Thank you all.. I'm sure I will be back. – lucidphreak Jul 12 '18 at 17:23

0 Answers0