473,549 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ 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\searc h.php on line 39

can anyone help
Oct 25 '12 #1
2 1896
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
1991
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 or assembly name xxxxxxx.dll, or one of its dependencies, was not found.." ///I got error at this point
8
9994
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 the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/WebApplication1'. 'HTTP/1.1 500...
5
9107
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 lWebResponse = (HttpWebResponse) lWebRequest.GetResponse(); StreamReader lResponseStream = new...
1
2501
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 following reason(s): The project file or web has been moved, renamed or is not on your computer.
21
3809
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 this property or method'. <form name="myform" action="main.asp" method="post"> <div id="content"> <h2 id="pageName">Main Page</h2> <div...
2
2778
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); HttpContext.Current.Session = DateTime.Now; For the above two methods I'm getting error as "Object reference not set to an instance of an object."
4
4011
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 called purchase_register_details, In sub form i have a unbound textfield called txt_Total_Amount where in i am calculating total amount for different...
12
6803
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 mounting, getting error "Could not resolve mount point". # mkdir /mnt/winstuff # smbmount \\windows-machine-ip-addr\CheckIn Could not resolve...
2
3203
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 know why this is so? Detailed error is like: Internal Server Error The server encountered an internal error or misconfiguration and was unable...
1
1542
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 condition which is in bold letters. If i give value its working like where CampaignID=1 alter PROCEDURE SAR_Sp_GetForecastedHC(@date1 DATETIME,...
0
7546
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7471
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7740
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7985
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7830
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6071
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3517
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1962
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 we have to send another system
1
1082
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.