473,396 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

php getting row from database using users id

im getting a issue where $ variables are getting ignored and do not know why here is the error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

here is the code
Expand|Select|Wrap|Line Numbers
  1. <center>
  2. <title>J~Net Balance Accounts</title>
  3. <?php
  4. // Connects to your Database
  5. mysql_connect("localhost", "root", "password") or die(mysql_error());
  6. mysql_select_db("messages") or die(mysql_error());
  7. $data = mysql_query("SELECT * FROM users where id = $id")
  8. or die(mysql_error());
  9. Print "<table border cellpadding=3>";
  10. while($info = mysql_fetch_array( $data ))
  11. {
  12. Print "<tr>";
  13. Print "<th>User:</th> <td>".$info['user_name'] . "</td> ";
  14. Print "<th>Balance:</th> <td>".$info['balance'] . " </td></tr>";
  15. }
  16. Print "</table>";
  17. ?> 

any ideas please anyone as it might be something silly
Oct 14 '11 #1
2 2074
Rabbit
12,516 Expert Mod 8TB
I don't see where $id is defined or initialized anywhere.
Oct 14 '11 #2
NeoPa
32,556 Expert Mod 16PB
Please check When Posting (VBA or SQL) Code. This applies to you as you're asking about SQL but only posting your PHP code.

Nevertheless, your problem is in line #7, as you'd see easily if you'd posted the SQL itself.
Oct 14 '11 #3

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

Similar topics

0
by: Kate Perry | last post by:
I am trying to execute a query on a db2 database using the dbi module. I'm wondering if someone can take a look at my code and tell me what I'm doing wrong. I'm assuming it's a problem with my...
6
by: Jeff Sandler | last post by:
I have a database I created in mySQL. I've been entering data every day into the database using a Java application that I wrote. The database and the Java program are on the same Win 98 SE...
10
by: Janelle.Dunlap | last post by:
In the database that I am creating I need to be able to rename the file with a name that the user specifies using the Save As Dialog window (I already have the code that brings up this window). In...
1
by: wlupton | last post by:
Hi All; My problem is getting information from an Access database using a partial string in VB6. The database consists of tables of information on motor vehicles including a 17 character VIN...
8
by: menmysql | last post by:
i am not bale to solve this problem since two weeks i am trying to access records from mysql database using jsp. inside this jsp program i wrote all my JDBC code. it is working very nicely and...
1
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as...
2
kaleeswaran
by: kaleeswaran | last post by:
hi! i want to know ..how to getting multiple rows from the database using ajax.and i pass these value to the javascript.give me solution... ...
6
by: ndeeley | last post by:
Hi, How do I insert a null or blank field into a database using coldfusion? I'm new to CF and its proviing a bit tricky! My database date field accepts null values (I think - theres no default...
12
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am a newbie to Struts and JSP...I have been working on the code below for 5 hours now..I googled a lot but couldn't get much help so finally I am here.. Hoping of getting my problem solved. Please...
10
by: James Bowyer | last post by:
As in the (x) in the top right hand corner of the screen. I have a log out and Exit button, which removes users from a list to let me know who is logged in and who isn't, however no matter how...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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
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...
0
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,...

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.