Site Search Problems: Need Help!

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
User avatar
swirlee
Moderator
Moderator
Posts: 2257
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Sat Jul 19, 2003 10:09 am

stevebob, the first step in solving a MySQL problem is seeing if your query actually works. So instead of running your query straight away, echo it and see what it looks like. If it still looks alright, copy and paste it to the MySQL console (mysql.exe, try "mysql --help" for more info) and see if it works. If it works, then you know that it's a PHP problem, not a MySQL problem.

My guess is that there's something wrong with your regular expressions, but that's not my department. Give the above a go and let us know what happens.

And as a side note, you don't need to use backticks (`) to surround column names unless your column names happen to be reserved words or have unusual markup, neither of which seems to be the case.
Image

User avatar
WiZARD
Moderator
Moderator
Posts: 1240
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Mon Jul 21, 2003 2:08 am

Hi!
first:

Code: Select all

$username="username";
$password="pass";
$database="dbname";
$conn = mysql_connect("localhost",$username,$password) or die( "Unable to connect: " . $my_sqlerror());
$dbase=mysql_select_db($database) or die( "Unable to select database: " . $my_sqlerror());

$query= "SELECT * FROM `search`";
$result=mysql_query($query);
$num=mysql_numrows($result);

and second:

Code: Select all

$id=mysql_result($result,$i,"id");
//`words`: where formatted text goes
$query2 = "UPDATE `search` WHERE `id` = " . $id . " SET `words` = " . $text;
mysql_query($query2);
   
   ++$i;
}
   
mysql_close();
"Sex,Drugs and Rock&Roll " replaced at "Sucks,Bugs and Plug&Play";
Image

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests