Jump to content

[SOLVED] MySQL Problem or PHP problem?


kigroy

Recommended Posts

I'm running WAMPSERVER 2.0 MySQL 5.1.30 and PHP 5.2.7.

 

In my database, db, I have a table, tb, with a column, cl.  In cl I have 5 cells that contain the word test.  I made my query in phpMyAdmin and it finds the 5 cells that contain the word test in cl of tb, but when I run it in my php code my variable assigned to the query array returns on the instance of the word test.  Thoughts?

 

		$query = "SELECT cl FROM tb WHERE (`cl` LIKE '%$name%')";  /* $name set from form that I know works*/
	$result = mysql_query($query, $conn);

	$row=mysql_fetch_array($result)
                print_r($row);

Link to comment
Share on other sites

PHP. You need a loop.

 

<?php

$query = "SELECT cl FROM tb WHERE (`cl` LIKE '%$name%')";  /* $name set from form that I know works*/
if ($result = mysql_query($query, $conn)) {
  if (mysql_num_rows($result)) {
    while ($row = mysql_fetch_array($result)) {
      print_r($row);
    }
  }
}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.