Selecting a

selecting a myText


[COLOR="Blue"](n) say[/COLOR]

(1) myText1
(2) [COLOR="red"]myText2[/COLOR]
(3) myText3

I have myTable like the above.
I like to get the text “myText2” which is in (2) in php.

The following is trial code for it. And it causes an error.

<?
$connect=mysql_connect("localhost","root","******");
?>

<?php
$mysql=mysql_select_db("php02",$connect);
?>

<?php
$query="select say from myTable where n=2;
?>

Could you fix it?

What is the error you are getting?

Also, you need to run the query using mysql_query()

Your can see the error at http://dot.kr/x-test/05.php (temperal URL).

The following is all code in the page of 05.php.

<!doctype html>
<html>
 
  <head>
    <meta charset="UTF-8">
    <title>test05</title>
  </head>

<body>
<?
$connect=mysql_connect("localhost","root","******");
?>

<?php
$mysql=mysql_select_db("php02",$connect);
?>

<?php
$query="select say from adText where n=2;
?>

</body>
</html>

You haven’t properly closed that last string. See below, I’ve added a double quote in bold red:

<!doctype html>
<html>
 
  <head>
    <meta charset="UTF-8">
    <title>test05</title>
  </head>

<body>
<?php
$connect=mysql_connect("localhost","root","******");
$mysql=mysql_select_db("php02",$connect);
$query="select say from adText where n=2[B][COLOR="Red"]"[/COLOR][/B];
?>

</body>
</html>

Also, there is no reason to go in and out of PHP all the time, so I just made one big PHP block.
Lastly, like Kalon said, you still need to run the query using [fphp]mysql_query[/fphp] and then get the results using [fphp]mysql_fetch_array[/fphp] or [fphp]mysql_fetch_assoc[/fphp] or any of the other mysql_fetch_* functions.

I don’t normally click posted links. Can you post the error message.

You still don’t actually run the query anywhere in your code.

Where do you actually run the query?