hi, i selected everything from the table and the direct variable $cResult[3] would give me something like "street address with space as delimiter" ... however, when i tried to use it, it will give me only "street" instead of "street address with space as delimiter".

does anyone know how i can fix it so it will show the whole field?
thanks

<?php
	require_once('auth.php');
	require_once('config.php');
	
	$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
	if(!$link) 
	{
		die('Failed to connect to server: ' . mysql_error());
	}
	
	//Select database
	$db = mysql_select_db(DB_DATABASE);
	if(!$db) 
	{
		die("Unable to select database");
	}
	
	$cid = $_SESSION['SESS_CUSTOMER_ID'];
	
	$qry="SELECT fname, lname, email, streetAddress,zip_id, passwd FROM customer WHERE customer_id='$cid'";

/////////////////// problem begin //////////////////////////////////	
        $cResult=mysql_fetch_array(mysql_query($qry));
	
	$fn= "$cResult[0]";
	$ln= "$cResult[1]";
	$email= "$cResult[2]";
	$street= "$cResult[3]";   //---> this will give me only part of the field (the first word basically)  
///////////////// problem end ///////////////////////////////

Try replacing the problem area with the following:

$cResult=mysql_fetch_array(mysql_query($qry));
$fn=$cResult[0];
$ln=$cResult[1];
$email=$cResult[2];
$street=$cResult[3];

Try replacing the problem area with the following:

$cResult=mysql_fetch_array(mysql_query($qry));
$fn=$cResult[0];
$ln=$cResult[1];
$email=$cResult[2];
$street=$cResult[3];

i will try again later but i think i already tried that and didn't work.

Member Avatar for diafol

Just a thought, is your 4th field (street) long enough to take the whole street name. Check in phpmyadmin or whatever you use to admin your db to see if the data in 'street' is complete.

If this ain't a problem, have you got any strange characters following the first word?

Just a thought, is your 4th field (street) long enough to take the whole street name. Check in phpmyadmin or whatever you use to admin your db to see if the data in 'street' is complete.

If this ain't a problem, have you got any strange characters following the first word?

nope, no strange characters. the field is long enough and the street i inserted "132 main street" was already stored in the table.

but it is weird that echo "$cResult[3]" returns me only "132"

but it is weird that echo "$cResult[3]" returns me only "132"

Perhaps it is an error in the part of the script that inserts into the table. Try using the mysql_real_escape_string() function to see if it escapes the spaces. And remember to put quotes around each string to be inserted. Below is an example:

echo '`column`="'.mysql_real_escape_string('132 main street').'"';
mysql_query('INSERT INTO `table` SET `column`="132 main street"') or die(mysql_error());

And check if the first line returns whats in the mysql query.

still don't know why, but it magically works now with $street= $cResult[3]


and echo "$cResult[3]" return "132 main street"

..... thanks everyone tried to help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.