cksrealm Posted April 30, 2007 Share Posted April 30, 2007 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 More sharing options...
esukf Posted April 30, 2007 Share Posted April 30, 2007 missing end double quote. <?php echo " The customer name is $row['number'] and the number is $row['number'] "; ?> Link to comment https://forums.phpfreaks.com/topic/49283-solved-php-database-query-question/#findComment-241481 Share on other sites More sharing options...
cksrealm Posted April 30, 2007 Author Share Posted April 30, 2007 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'] "; Link to comment https://forums.phpfreaks.com/topic/49283-solved-php-database-query-question/#findComment-241499 Share on other sites More sharing options...
Gobbo Posted April 30, 2007 Share Posted April 30, 2007 <?php echo " The customer name is $row['custname'] and the number is $row['number'] "; ?> What you need to do is this: <?php echo " The customer name is ". $row['custname'] ." and the number is ". $row['number'] ." "; ?> Link to comment https://forums.phpfreaks.com/topic/49283-solved-php-database-query-question/#findComment-241514 Share on other sites More sharing options...
cksrealm Posted April 30, 2007 Author Share Posted April 30, 2007 Works a treat thanks alot guys CK Link to comment https://forums.phpfreaks.com/topic/49283-solved-php-database-query-question/#findComment-241528 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.