Jump to content

[SOLVED] PHP database query question


cksrealm

Recommended Posts

Hi all

 

I have a MySQL database that I am trying to write a script for. Basically the database gets updated with customer records which are then used to create a configuration line. within this database there is an auto_increment field called number which I need to pull data from.

 

I have managed to get the number is I write a manual query each time but I need to work with inputted data. For example

 

<?php

// Make a MySQL Connection

mysql_connect($server,$user,$password) or die(mysql_error());

mysql_select_db("test") or die(mysql_error());

echo $query_string;

 

// Retrieve all the data from the  table

$result = mysql_query("SELECT number FROM customer WHERE custname='$custname'")

or die(mysql_error()); 

 

// store the record of the "example" table into $row

 

$row = mysql_fetch_array( $result );

 

// Print out the contents of the entry

 

echo "Based on the details given the line you need is this<BR>\n";

echo " The customer name is $row['number'] and the number is $row['number'];

 

When I run this I get the following error each time

 

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/chrisk/asa/scripts/generateconfig.php on line 87

 

Line 87 reads

 

echo " The customer name is $row['number'] and the number is $row['number'];

 

Any help would be greatly appreciated.

 

Thanks

 

CK

 

 

Link to comment
https://forums.phpfreaks.com/topic/49283-solved-php-database-query-question/
Share on other sites

Still getting the same error.

 

 

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/chrisk/asa/scripts/generateconfig.php on line 92

 

Line 92 is

 

echo " The customer name is $row['custname'] and the number is $row['number'] ";

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.