PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$sql = "SELECT * FROM intra_user WHERE nome LIKE '%" . trim(substr($v['nome'], 6, 15)) . "%'";
$rs = $this->db->conn->Execute($sql) or die("Error in query: " . $this->db->conn->ErrorMsg());
ok .. no error results ... and no result in my select...
but... if i get SQL code and put on my phpmyadmin he return results...
$sql = "SELECT * FROM intra_user WHERE nome LIKE '%noronha%'";
$rs = $this->db->conn->Execute($sql) or die("Error in query: " . $this->db->conn->ErrorMsg());
i get results... but if i use trim(substr($v['nome'], 6, 15)); i dont receive any result and any errors..
why?
thanks
Last edited by salsa on Fri May 16, 2008 11:54 am, edited 2 times in total.
I don't think its a problem with using the trim inside of the query. It looks to me that the problem is you're not fetching the results from the query and storing them anywhere. For instance:
<?php
$result = mysql_query("SELECT * from Tablename");
//if you leave this out $row won't have a value
$row = mysql_fetch_array($result);
echo $row['fieldname'];
$v['nome'] = "something";
mysql_connect("localhost", "username", "pass")
or die ('there was a connection error: ' . mysql_error());
mysql_select_db("tablename")
or die ('there was a table select error: ' . mysql_error());
$result = mysql_query("SELECT * FROM intra_user WHERE nome LIKE '%" . trim(substr($v['nome'], 6, 15)) . "%'")
or die ('there was an error: ' . mysql_error());
$row = mysql_fetch_array($result)
or die ('mysql array fetch error: ' mysql_error());
print_r($row);
It sounds like you're having problems a) connecting to the database or b) getting info from the table. Try running this code, it will tell you where exactly you problem is and you can go from there.
From
Last edited by Jade on Thu May 29, 2008 3:00 pm, edited 1 time in total.
set_time_limit(0);
$handle = @fopen("temp/myfile.txt", "r");
while (!feof($handle)) {
$linha = fgets($handle, 4096);
mysql_connect('localhost', 'myuser', 'mypass') or die ('there was a connection error: ' . mysql_error());
mysql_select_db(DATABASE) or die ('there was a table select error: ' . mysql_error());
$result = mysql_query("SELECT * FROM intra_user WHERE nome LIKE '%" . trim(substr($linha, 6, 15)) . "%'") or die ('there was an error: ' . mysql_error());
$row = mysql_fetch_array($result) or die ('mysql array fetch error: ' . mysql_error());
print_r($row);
}
fclose($handle);