473,387 Members | 1,834 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,387 software developers and data experts.

Proplems with variable in PHP script for MySQL..

80
Could anyone explain to me why I dont get any info from this code?

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $strID = $_GET["id"];
  3. echo $strID . "<br>";
  4.  
  5. $con = mysql_connect("someserver","someuser","somepass");
  6. if (!$con)
  7.   {
  8.   die('Could not connect: ' . mysql_error());
  9.   }
  10.  
  11. mysql_select_db("db_doc", $con);
  12.  
  13. $result = mysql_query("SELECT * FROM docx_main WHERE ID= 'strID'");
  14.  
  15. while($row = mysql_fetch_array($result))
  16.   {
  17.   echo $row['doc_titel'] . "<br />" . $row['doc_body'];
  18.   echo "<br />";
  19.   }
  20. ?> 
It showes that the strID is right, when calling page?id=2 but it echoes no text from DB, if I remove the
Expand|Select|Wrap|Line Numbers
  1.  WHERE ID= 'strID'
it print every post.. So spelling and (everything) must be right, but why not when using WHERE?

Thanks for any reply!
Frederik
Jun 11 '09 #1
4 1243
Markus
6,050 Expert 4TB
Try adding or die(mysql_error()); to your mysql_* functions.

Expand|Select|Wrap|Line Numbers
  1. $result = mysql_query("SELECT * FROM docx_main WHERE ID= 'strID'") or die(mysql_error());
  2.  
Jun 11 '09 #2
Dormilich
8,658 Expert Mod 8TB
@Pheddy
maybe you mean
Expand|Select|Wrap|Line Numbers
  1.  WHERE ID= '$strID'
Jun 11 '09 #3
Pheddy
80
Hehe sometimes a problem seems so complex, and most of the time you just need to add $ :D Thanks Dor..
Jun 11 '09 #4
Dormilich
8,658 Expert Mod 8TB
yea, a dollar makes the world go round *g*
Jun 12 '09 #5

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

Similar topics

2
by: Erik Andersson | last post by:
Hi! <? class Foo { function getMessage() { return "foo"; } } class Bar { function getFoo() {
1
by: Rhio Barnhart | last post by:
I am a MySQL/PHP beginner and have gotten further than I expected. I am developing a web based library catalog. After getting everything configured, I have been working on various query formats. ...
0
by: Duane Winner | last post by:
Hello all - I'm having a small problem with the mysql startup script that ships with MySQL-3.23.56-1. I'm running on RedHat Linux. It works fine, but I have a backup server that runs a script...
7
by: Donna Hawkins | last post by:
I want to use javascript to redirect to a URL which has been passed as a variable (in php). I have searched but cannot find any solution. I think this code is a basic redirect: <script...
5
by: strawberry | last post by:
In the function below, I'd like to extend the scope of the $table variable such that, once assigned it would become available to other parts of the function. I thought 'global $table;' would solve...
4
by: baccaril | last post by:
Hello, I have a form the post to a php script, the variable is passed to the php script successfully. I then query MySQL and output 8 rows at a time. So the problem I'm having is the first 8...
2
by: Boujii | last post by:
Greetings, I have been attempting to make a drop down menu of countries. From this menu I wish to create a variable in order to INPUT into mysql database. I have no trouble making the drop down menu,...
1
by: satish2112 | last post by:
Hi, I have a text-area which contains values from mysql database and 2 buttons, Edit and Update. When I click on the Edit button, I can edit the text-area (initially non-editable). After this,...
8
by: xtremebass | last post by:
Hi Bytes.. i have need to assign Mysql Database DataField value to shell script variable . is it possible ? i have tried like this .. got error.. #!bin/sh password=xxx mysql -u root...
1
ssnaik84
by: ssnaik84 | last post by:
Hi Guys, Last year I got a chance to work with R&D team, which was working on DB scripts conversion.. Though there is migration tool available, it converts only tables and constraints.. Rest of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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,...
0
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...

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.