Page 1 of 1
Adodb, Select Like no result
Posted: Fri May 16, 2008 9:36 am
by salsa
Hey guys...
i have a problem when i try to execute a SELECT...
1. i print that code...
Code: Select all
print trim(substr($v['nome'], 6, 15));
and he return "
noronha"
ok... after i run my SQL
Code: Select all
$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...
example...
if i use...
Code: Select all
$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
Re: Adodb, Select Like no result
Posted: Fri May 16, 2008 11:26 am
by Jade
Hey there,
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:
Code: Select all
<?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'];
Re: Adodb, Select Like no result
Posted: Fri May 16, 2008 11:51 am
by salsa
Hey, thanks to reply my post...
When i execute i execute fetch in adodb using geRows ... but no results...
Code: Select all
<?
foreach ($rs->getRows() as $row) {
print $row['id']."<br>";
}
?>
but in phpmyadmin ... select works fine... :/
Re: Adodb, Select Like no result
Posted: Mon May 19, 2008 3:00 pm
by Jade
Try doing this and see what's actually in $rs. Maybe you're accessing something that isn't there.
Code: Select all
print_r($rs);
print_r($rs->getRows());
Re: Adodb, Select Like no result
Posted: Tue May 20, 2008 12:26 pm
by salsa
hey Jade...
nothing in $rs ... but if i get SQL code and put on phpMyAdmin .. i get results :/
i try to change adodb to mysql_connect, mysql_select_db and mysql_query but i got same error :/
Re: Adodb, Select Like no result
Posted: Tue May 20, 2008 4:11 pm
by Jade
Try this:
Code: Select all
$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
Re: Adodb, Select Like no result
Posted: Wed May 21, 2008 11:56 am
by salsa
i got:
mysql array fetch error:
and no msg... :p
but if i print
Code: Select all
print "SELECT * FROM intra_user WHERE nome LIKE '%" . trim(substr($v['nome'], 6, 15)) . "%'";
and put on phpmyadmin and run.... he running ok :p
Re: Adodb, Select Like no result
Posted: Wed May 21, 2008 3:43 pm
by Jade
Sorry, its an error in the code I gave you. Change this line:
Code: Select all
or die ('mysql array fetch error: ' mysql_error());
To this:
Code: Select all
or die ('mysql array fetch error: ' . mysql_error());
Re: Adodb, Select Like no result
Posted: Thu May 22, 2008 7:56 am
by salsa
relax jade...
i fix that small error before run that script...
so i got error
salsa wrote:i got:
mysql array fetch error:
and no msg... :p
but if i print
Code: Select all
print "SELECT * FROM intra_user WHERE nome LIKE '%" . trim(substr($v['nome'], 6, 15)) . "%'";
and put on phpmyadmin and run.... he running ok :p
Re: Adodb, Select Like no result
Posted: Wed May 28, 2008 7:12 am
by salsa
Code: Select all
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);
return...... "mysql array fetch error: "
anybody can help me?

Re: Adodb, Select Like no result
Posted: Thu May 29, 2008 3:02 pm
by Jade
Sounds like something is wrong with your mysql maybe? I'm not sure, can you get it to query for other things outside of phpmyadmin?