Jump to content

odbc echo problem


DarkPrince2005

Recommended Posts

Can anyone tell me why this is just echoing empty lines?

 

When I do it in mysql it works.

 

<?php

$conn=odbc_connect('helpdesk','','');
$sql="SELECT * FROM invoices";
$rs=odbc_exec($conn,$sql);
while(odbc_fetch_row($rs)){

mysql_connect("localhost","root","");
mysql_select_db("db");
$len = strlen(odbc_result($rs,"Invoice_ID"));
//echo $len;
if($len == "12"){
$new = str_replace("ITEC_Inv-00","ITECnerv_Inv-0000",odbc_result($rs,"Invoice_ID"));
} else {
if($len == "13"){
$new = str_replace("ITEC_Inv-00","ITECnerv_Inv-000",odbc_result($rs,"Invoice_ID"));
} else {
	if($len == "14"){
	$new = str_replace("ITEC_Inv-00","ITECnerv_Inv-00",odbc_result($rs,"Invoice_ID"));
	} else {
$new = odbc_result($rs,"Invoice_ID");
}
}
}

echo $new."<br />";
}

Link to comment
https://forums.phpfreaks.com/topic/242716-odbc-echo-problem/
Share on other sites

Integers are not quoted in php (or any other languages I know of).

 

As for your issue, what debugging have you done? You haven't checked your query has succeeded or returns any results.Have you tried simply echoing the results within all the string replacing?

 

Also, opening a mysql connection like that within a loop is never going to be a wise idea.

Link to comment
https://forums.phpfreaks.com/topic/242716-odbc-echo-problem/#findComment-1246662
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.