473,486 Members | 2,394 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Getting error

3 New Member
Expand|Select|Wrap|Line Numbers
  1. while($data_fetch=mysql_fetch_array($query_for_result))
  2. {
  3.     echo "<li>";
  4.     echo '<a href="<?php echo $user_data['username']; ?>">' .
  5.     substr($data_fetch[$db_tb_atr_name], 0,160). '</a>';
  6.     echo "</li><hr/>";
  7. }
but keeping getting this error

Parse error: syntax error, unexpected 'username' (T_STRING), expecting ',' or ';' in D:\xampp\htdocs\Register\search.php on line 39

can anyone help
Oct 25 '12 #1
2 1892
johny10151981
1,059 Top Contributor
yes you should get this error. I will give you a simple tip to avoid this dumb error. just follow the statement below:

Expand|Select|Wrap|Line Numbers
  1. while($data_fetch=mysql_fetch_assoc($query_for_res ult)) //array create both string and integer indexing. which is not very useful but unnecessary
  2. {
  3. echo "<li>";
  4. echo '<a href="'.$user_data['username'].'">'.
  5. substr($data_fetch[$db_tb_atr_name], 0,160). '</a>';
  6. echo "</li><hr/>"; //I am not sure what you have wanted with this code but I have changed as i think it sould be. but still the output wont work properly cause your href will fail
  7. }
  8.  
now can you see and tell the difference?
Oct 25 '12 #2
Rabbit
12,516 Recognized Expert Moderator MVP
You can use johny's method. But what you are trying to do can work if you use the correct syntax.

1) Variables are only interpreted within strings if the string is demarcated with double quotes.

2) When you want to interpret complex variables or constants in a string, you need to surround them in braces.

Expand|Select|Wrap|Line Numbers
  1. echo "{someArray['foo']}";
Oct 25 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1980
by: IMS.Rushikesh | last post by:
Hi Friends, My work is stuck up because of this unresolvable and unbelievable Error. I'm trying to Serialize my Class object using XmlSerialization. And at below line, I m getting "error File...
8
9986
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
5
9102
by: Archana | last post by:
Hi all, I am having application where i am downloading xml content using webrequest. my code is as below HttpWebRequest lWebRequest = (HttpWebRequest) WebRequest.Create(URL); HttpWebResponse...
1
2495
by: jonny | last post by:
Went from using Visual Web Develop express to Visual Studio 2005 and getting error when trying to open project. Error message: "One or more projects in the solution could not be loaded for the...
21
3794
vikas251074
by: vikas251074 | last post by:
I am getting error while entry in userid field. When user enter his user id, an event is fired immediately and user id is verified using AJAX method. But I am getting error 'Object doesn't support...
2
2776
by: sony.m.2007 | last post by:
Hi, When i try to set a value for a session variable I'm getting a object refence not set error I tried two methods as below HttpContext.Current.Session.Add("AppStartTime", DateTime.Now);...
4
4008
by: sumit kale | last post by:
Hi, Can somebody help me resolve my problem ? I am getting error when calculating total using unbound textfiled in subform. I have a main form called purchase_register_master and a subform...
12
6789
by: tvnaidu | last post by:
Trying to mount windows folder on Linux machine, getting this error. I have a folder called "CheckIn" on windows, I made that folder as Network sharing. ON lInux, I tried to access that folder by...
2
3198
by: bandy | last post by:
Hi there sorry If I posted this thread under wrong head. When I am trying to run my site I am getting error as Internal Server Error, but when I refresh page , i get result properly. I don't...
1
1540
by: NareshN | last post by:
Hi, I am getting error in following stored procedure in where condition Must declare the scalar variable "@CampaignId".I already declared CampaignId but still getting error.Please see where...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.