Global Temporary Table Creation Failed - php

i have some link which show data on iframe with the help of temporary data from database
i am fetching this data with the help of query strings
the page with Links is
<style type="text/css">
a
{
text-decoration:none;
}
.Menu
{
width:150px;
float:left;
}
.fr
{
width:800px;
height:800px;
float:right
}
</style>
<div class="Menu">
<?php
mysql_connect("localhost","dbname","password");
mysql_select_db("dbname");
$sql="select * from NSEIndices_latest";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{
$tpnt=$row['TickerPlantCode']; //nse indice code
$indexname=$row['IndexName']; //nse indice index name
?>
<tr>
<td><?php echo $indexname;?><br></td>
</tr>
<?php }?>
</div>
<div class="fr">
<iframe height="780" width="780" scrolling="no" name="fr"></iframe>
</div>
Now the link from above page fetch data with the help of query string at this page a temporary table is created by collectiong data from various tables
but am getting error while retrieve data from that temporary table
the page with temporary table is
<table class="table" cellspacing="0" width="100%">
<tr>
<td align="left" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9;">Company Name
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">High
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Low
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Last Price
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Prv Close
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Change
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">%Gain
</th>
</tr>
<?php
mysql_connect("localhost","dbname","password");
mysql_select_db("dbname");
$tpnt=$_GET['tpnt'];
$indexname=$_GET['indexname'];
echo "1".$indexname. "<br>";
$query="SELECT nsepricequotes_latest.Symbol, nsepricequotes_latest.CompanyName, nsepricequotes_latest.HighPrice, nsepricequotes_latest.LowPrice, nsepricequotes_latest.LastTradedPrice, nsepricequotes_latest.ClosePrice, nsepricequotes_latest.NetChange, nsepricequotes_latest.PercentChange, nse_index_constituents.Tickerplant_index_code,nse_index_constituents.NSE_Index_Name
FROM nsepricequotes_latest, nse_index_constituents
WHERE nsepricequotes_latest.TickerPlantCode = nse_index_constituents.TickerPlant_scrip
AND PercentChange >0
ORDER BY PercentChange DESC ";
$result=mysql_query($query);
echo "2".$indexname. "<br>";
while($row1=mysql_fetch_array($result))
{
$Symbol1=$row1['Symbol'];
$CompanyName1=$row1['CompanyName'];
$HighPrice1=$row1['HighPrice'];
$LowPrice1=$row1['LowPrice'];
$LastTradedPrice1=$row1['LastTradedPrice'];
$ClosePrice1=$row1['ClosePrice'];
$NetChange1=$row1['NetChange'];
$PercentChange1=$row1['PercentChange'];
$Tickerplant_index_code1=$row1['Tockerplant_index_code1'];
$NSE_Index_Name1=$row1['NSE_Index_Name'];
}
echo "3".$indexname. "<br>";
$tbl="create GLOBAL TEMPORARY TABLE temppice(Symbol varchar(100),CompanyName varchar(200),HighPrice float(50),LowPrice float(50),LastTradedPrice float(50),ClosePrice float(50),NetChange float(50),PercentChange float(50),Tickerplant_index_code varchar(100),NSe_Index_Name varchar(100)) ON COMMIT DELETE ROWS;";
$res=mysql_query($tbl);
if (!$res) { die('Temporary table creation failed: ' . mysql_error()); }
if(mysql_error())die(mysql_error());
$intbl="Insert into temppice values('$Symbol1','$CompanyName1','$HighPrice1','$LowPrice1','$LastTradedPrice','$ClosePrice1','$NetChange1','$PercentChange1','$Tockerplant_index_code1','$NSE_Index_Name1')";
mysql_query($intbl);
if(mysql_error())die(mysql_error());
echo "4".$indexname. "<br>";
$query1="Select * from temppice where NSE_Index_Name=$indexname";
$result1=mysql_query($query1);
//if(mysql_error())die(mysql_error());
mysql_connect("localhost","dbname","password");
mysql_select_db("dbname");
while($row=mysql_fetch_array($result1, MYSQL_BOTH))
{
$symbol=$row['Symbol'];
$CompanyName=$row['CompanyName'];
$HighPrice=$row['HighPrice'];
$LowPrice=$row['LowPrice'];
$previousclose=$row['LastTradedPrice'];
$ClosePrice=$row['ClosePrice'];
$netChange=$row['NetChange'];
$percentagechange=$row['PercentChange'];
?>
<tr>
<td align="left" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $CompanyName;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $HighPrice;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $LowPrice;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $previousclose; ?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $ClosePrice;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $netChange;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $percentagechange;?></td>
</tr>
<?php } ?>
</table>
the error am getting is
Temporary table creation failed: You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near 'GLOBAL TEMPORARY TABLE
temppice(Symbol varchar(100),CompanyName varchar(200),Hig' at line 1

According to the manual the MySQL CREATE TABLE syntax does not support the global keyword. That appears to be an Oracle thing. Likewise I believe that the ON COMMIT DELETE ROWS clause is part of the Oracle syntax which will not work in MySQL either.
If you remove those two parts it will probably work:
$tbl=<<<SQL
create TEMPORARY TABLE temppice (
Symbol varchar(100),
CompanyName varchar(200),
HighPrice float(50),
LowPrice float(50),
LastTradedPrice float(50),
ClosePrice float(50),
NetChange float(50),
PercentChange float(50),
Tickerplant_index_code varchar(100),
NSe_Index_Name varchar(100)
);
SQL;

Related

Generate Excel File with specific group of output

Can someone or somebody help me with my code or with my SQL execution? I'd like to create an excel file based on a specific group of data based on the event/activity they participated in.
Here is my code:
$program_admin = $_SESSION['username'];
$actvty_ID = $_POST['id'];
//$activitydate = $_POST['activity_date'];
if(isset($_POST['export_in_excel'])) {
$excel_sql = "SELECT *
FROM projectcode pj
INNER JOIN activities ac ON ac.projects_id = pj.projects_id
INNER JOIN participants re ON re.act_id = ac.id
WHERE pj.project_code='$program_admin'
ORDER BY re.id DESC "; //pj.project_code='$program_admin'
$excel_result = mysqli_query($connect, $excel_sql);
if(mysqli_num_rows($excel_result) > 0) {
$excel_output .='
<table class="excel_table" style="font-family:Calibri; border:1px solid #1f004d;">
<tr><td></td></tr>
<tr>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d;">No.</th>
<th colspan="2" style="text-align:center; font-weight:bold; border:1px solid #1f004d;">Name</th>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d; ">Age</th>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d; ">Gender</th>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d; ">City/Municipality</th>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d; ">Province</th>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d; ">Contact No.</th>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d; ">Email Address</th>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d; ">Organization</th>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d; ">Signature</th>
</tr>
';
$no = 1;
while($excel_row = mysqli_fetch_array($excel_result)) {
$excel_output .='
<tr>
<td style="text-align:center;">'.$no.'</td>
<td>'.$excel_row["firstname"].'</td>
<td>'.$excel_row["lastname"].'</td>
<td>'.$excel_row["agerange"].'</td>
<td>'.$excel_row["gender"].'</td>
<td>'.$excel_row["city_municipality"].'</td>
<td>'.$excel_row["province"].'</td>
<td>'.$excel_row["mobileno"].'</td>
<td>'.$excel_row["email"].'</td>
<td>'.$excel_row["org_office"].'</td>
<td></td>
</tr>
';
$no ++;
}
$excel_output .='</table>';
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=Attendance Sheet.xls");
echo $excel_output;
}
}
And here is the sample output of my code:
enter image description here

Why this code places the - sign at the last

I am using below code to display advanced custom field (date fields) in wordpress. I want two dates to appear like e.g 12 mar - 15 mar 2017.
I am using this code
<?php echo the_sub_field('start_date').' - '.the_sub_field('end_date'); ?>
How to do it please explain ?
Right now I am getting result like this 18/09/201722/09/2017 -
my full html code
<table style=" border-collapse: collapse; table-layout: fixed; width: 800px;">
<tbody>
<tr>
<td style="border: 1px solid #ddd;"><h5 style="color:#044970;">Refernce</h5></td>
<td style="border: 1px solid #ddd;"><h5 style="color:#044970;">Dates</h5></td>
<td style="border: 1px solid #ddd;"><h5 style="color:#044970;">Venue</h5></td>
<td style="border: 1px solid #ddd;"><h5 style="color:#044970;">Fees</h5></td>
<td style="border: 1px solid #ddd;"><h5 style="color:#044970;">CPE Credits</h5></td>
<td style="border: 1px solid #ddd;"><h5 style="color:#044970;">Regsitrations</h5></td>
</tr>
</tbody>
</table>
<table style=" border-collapse: collapse; table-layout: fixed; width: 800px;">
<tbody>
<?php
if( have_rows('sub_seminars') ):
while( have_rows('sub_seminars') ) : the_row();
?>
<tr>
<td style="border: 1px solid #ddd;"><h6><?php the_sub_field('ref'); ?></h6></td>
<td style="border: 1px solid #ddd;"><h6><?php echo the_sub_field('start_date').' - '.the_sub_field('end_date'); ?></h6></td>
<td style="border: 1px solid #ddd;"><h6><?php the_sub_field('venue'); ?></h6></td>
<td style="border: 1px solid #ddd;"><h6><?php the_sub_field('fees'); ?></h6></td>
<td style="border: 1px solid #ddd;"><h6><?php the_sub_field('cpe_credits'); ?></h6></td>
<td style="border: 1px solid #ddd;"><a href="<?php home_url(); ?>/euromatechnew/seminar-registrations?seminartitle=<?php echo htmlentities(urlencode(get_the_title())) ?>&seminarvenue=<?php echo the_sub_field('venue');
?>&seminardates=<?php echo the_sub_field('start_date').the_sub_field('end_date'); ?>&seminarref=<?php echo the_sub_field('ref') ?>" class="dt-btn" style="margin: 3px 0px 0px 0px">Register Now</a></td>
</tr>
<?php
endwhile;
endif;
?>
</tbody>
</table>
the_sub_field function already echoes data.
To get data and then echo it - use get_sub_field.
Proper code is:
<?php echo get_sub_field('start_date').' - '.get_sub_field('end_date'); ?>
Or as with your markup:
<td style="border: 1px solid #ddd;"><h6><?php the_sub_field('start_date');?> - <?php the_sub_field('end_date');?></h6></td>
To format your dates as you need you can use date fomatting functions of php, e.g date.

How to add a delete and edit function into my HTML table which is filled with info from my MySQL database?

I've made this simple PHP/HTML table which shows info in my database, now i want to add a delete and edit function using the SQL DELETE and EDIT functions.
How can i implent this so that every row has a delete button and edit button automaticly when its added to the DB?
Table
<table style="border: 1px solid black;">
<tr>
<th style="border-bottom: 1px solid black;">CI nummer</th>
<th style="border-bottom: 1px solid black;">Aankoopdatum</th>
<th style="border-bottom: 1px solid black;">Serienummer</th>
<th style="border-bottom: 1px solid black;">Merk</th>
<th style="border-bottom: 1px solid black;">Model</th>
<th style="border-bottom: 1px solid black;">OS</th>
<th style="border-bottom: 1px solid black;">Eigenaar</th>
<th style="border-bottom: 1px solid black;">Locatie</th>
<th style="border-bottom: 1px solid black;">Bewerken</th>
<th style="border-bottom: 1px solid black;">Verwijderen</th>
</tr>
<?php
$conn = mysqli_connect("localhost", "root", "", "teradruk");
if (mysqli_connect_errno()) {
echo "Kan geen verbinding maken met de database!";
exit();
}
$sqli = "SELECT * FROM `hardware`";
if ($stmti = $conn->prepare($sqli)) {
if (!$stmti->execute()) {
echo "cant exec: <br> " . $stmti->error;
exit();
} else {
$stmti->bind_result($cinummer, $aankoopdatum, $serienummer, $merk, $model, $os, $eigenaar, $locatie, $applicatie);
$stmti->store_result();
while($stmti->fetch()) {
echo "<tr>
<td>$cinummer</td>
<td>$aankoopdatum</td>
<td>$serienummer</td>
<td>$merk</td>
<td>$model</td>
<td>$os</td>
<td>$eigenaar</td>
<td>$locatie</td>
</tr>";
}
}
} else {
echo "can't prepare: <br> " . $stmti->error;
exit();
}
?>
</table>
I just update the code. but I did not create a EDIT form in HTML and send values, I have write PHP codes
<table style="border: 1px solid black;">
<tr>
<th style="border-bottom: 1px solid black;">CI nummer</th>
<th style="border-bottom: 1px solid black;">Aankoopdatum</th>
<th style="border-bottom: 1px solid black;">Serienummer</th>
<th style="border-bottom: 1px solid black;">Merk</th>
<th style="border-bottom: 1px solid black;">Model</th>
<th style="border-bottom: 1px solid black;">OS</th>
<th style="border-bottom: 1px solid black;">Eigenaar</th>
<th style="border-bottom: 1px solid black;">Locatie</th>
<th style="border-bottom: 1px solid black;">Bewerken</th>
<th style="border-bottom: 1px solid black;">Verwijderen</th>
<th style="border-bottom: 1px solid black;">Options</th>
</tr>
<?php
$conn = mysqli_connect("localhost", "root", "", "teradruk");
if (mysqli_connect_errno()) {
echo "Kan geen verbinding maken met de database!";
exit();
}
if($_GET['action']=="delete")
{
$sql_delete = mysql_query("DELETE FROM hardware WHERE PRIMARY_KEY_OF_hardware_TABLE = ".$_GET['id']." ");
}
elseif($_GET['action']=="edit")
{
$sql_update = "UPDATE hardware SET cinummer = 'New Number' WHERE PRIMARY_KEY_OF_hardware_TABLE = ".$_GET['id']." ";
}
$sqli = "SELECT * FROM `hardware`";
if ($stmti = $conn->prepare($sqli)) {
if (!$stmti->execute()) {
echo "cant exec: <br> " . $stmti->error;
exit();
} else {
$stmti->bind_result($cinummer, $aankoopdatum, $serienummer, $merk, $model, $os, $eigenaar, $locatie, $applicatie);
$stmti->store_result();
while($stmti->fetch()) {
echo "<tr>
<td>$cinummer</td>
<td>$aankoopdatum</td>
<td>$serienummer</td>
<td>$merk</td>
<td>$model</td>
<td>$os</td>
<td>$eigenaar</td>
<td>$locatie</td>
<td><a href='filename.php?id=".$PRIMARY_KEY_OF_hardware_TABLE."&action=delete'>Delete</a> | <a href='filename.php?id=".$PRIMARY_KEY_OF_hardware_TABLE."&action=edit'>Edit</a></td>
</tr>";
}
}
} else {
echo "can't prepare: <br> " . $stmti->error;
exit();
}
?>
</table>
Thanks!

Working With Temporary Tables in MySQL

I have some link which show data on iframe with the help of temporary data from database
I am fetching this data with the help of query strings
The page with Links is
<style type="text/css">
a
{
text-decoration:none;
}
.Menu
{
width:150px;
float:left;
}
.fr
{
width:800px;
height:800px;
float:right
}
</style>
<div class="Menu">
<?php
mysql_connect("localhost","dbname","password");
mysql_select_db("dbname");
$sql="select * from NSEIndices_latest";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{
$tpnt=$row['TickerPlantCode']; //nse indice code
$indexname=$row['IndexName']; //nse indice index name
?>
<tr>
<td><?php echo $indexname;?><br></td>
</tr>
<?php }?>
</div>
<div class="fr">
<iframe height="780" width="780" scrolling="no" name="fr"></iframe>
</div>
Now the link from above page fetch data with the help of query string at this page a temporary table is created by collectiong data from various tables
but am getting error while retrieve data from that temporary table
the page with temporary table is
<table class="table" cellspacing="0" width="100%">
<tr>
<td align="left" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9;">Company Name
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">High
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Low
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Last Price
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Prv Close
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Change
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">%Gain
</th>
</tr>
<?php
mysql_connect("localhost","dbname","password");
mysql_select_db("dbname");
$tpnt=$_GET['tpnt'];
$indexname=$_GET['indexname'];
echo "1".$indexname. "<br>";
$query="SELECT nsepricequotes_latest.Symbol, nsepricequotes_latest.CompanyName, nsepricequotes_latest.HighPrice, nsepricequotes_latest.LowPrice, nsepricequotes_latest.LastTradedPrice, nsepricequotes_latest.ClosePrice, nsepricequotes_latest.NetChange, nsepricequotes_latest.PercentChange, nse_index_constituents.Tickerplant_index_code,nse_index_constituents.NSE_Index_Name
FROM nsepricequotes_latest, nse_index_constituents
WHERE nsepricequotes_latest.TickerPlantCode = nse_index_constituents.TickerPlant_scrip
AND PercentChange >0
ORDER BY PercentChange DESC ";
$result=mysql_query($query);
echo "2".$indexname. "<br>";
while($row1=mysql_fetch_array($result))
{
$Symbol1=$row1['Symbol'];
$CompanyName1=$row1['CompanyName'];
$HighPrice1=$row1['HighPrice'];
$LowPrice1=$row1['LowPrice'];
$LastTradedPrice1=$row1['LastTradedPrice'];
$ClosePrice1=$row1['ClosePrice'];
$NetChange1=$row1['NetChange'];
$PercentChange1=$row1['PercentChange'];
$Tickerplant_index_code1=$row1['Tockerplant_index_code1'];
$NSE_Index_Name1=$row1['NSE_Index_Name'];
}
echo "3".$indexname. "<br>";
$tbl="create TEMPORARY TABLE temppice(Symbol varchar(100),CompanyName varchar(200),HighPrice float(50),LowPrice float(50),LastTradedPrice float(50),ClosePrice float(50),NetChange float(50),PercentChange float(50),Tickerplant_index_code varchar(100),NSe_Index_Name varchar(100))";
$res=mysql_query($tbl);
if (!$res) { die('Temporary table creation failed: ' . mysql_error()); }
if(mysql_error())die(mysql_error());
$intbl="Insert into temppice values('$Symbol1','$CompanyName1','$HighPrice1','$LowPrice1','$LastTradedPrice','$ClosePrice1','$NetChange1','$PercentChange1','$Tockerplant_index_code1','$NSE_Index_Name1')";
mysql_query($intbl);
if(mysql_error())die(mysql_error());
echo "4".$indexname. "<br>";
$query1="Select * from temppice where NSE_Index_Name=$indexname";
$result1=mysql_query($query1);
//if(mysql_error())die(mysql_error());
while($row=mysql_fetch_array($result1, MYSQL_BOTH))
{
$symbol=$row['Symbol'];
$CompanyName=$row['CompanyName'];
$HighPrice=$row['HighPrice'];
$LowPrice=$row['LowPrice'];
$previousclose=$row['LastTradedPrice'];
$ClosePrice=$row['ClosePrice'];
$netChange=$row['NetChange'];
$percentagechange=$row['PercentChange'];
?>
<tr>
<td align="left" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $CompanyName;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $HighPrice;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $LowPrice;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $previousclose; ?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $ClosePrice;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $netChange;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $percentagechange;?></td>
</tr>
<?php } ?>
</table>
the error am getting is
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mastertr/public_html/master/wpfiles/gtnsegainers.php on line 58
TEMPORARY tables have lifetime of one connection, so if you create the table during one request from the browser, and then want to fetch data from it in another request.... it's no longer there. The table does not exist and your query fails with no such table in database error.

Get Data From a Table Created by Equi Join Query

i have a table created by my sql equijoin
and i want to retrieve data from that table by am getting error
the error is
dname.resource doesn't exist
and the code is
<style type="text/css">
a
{
text-decoration:none;
}
.Menu
{
width:150px;
float:left;
}
.fr
{
width:800px;
height:800px;
float:right
}
</style>
<div class="Menu">
<?php
mysql_connect("localhost","dbname","password");
mysql_select_db("dbanme");
$sql="select * from NSEIndices_latest";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{
$tpnt=$row['TickerPlantCode']; //nse indice code
$indexname=$row['IndexName']; //nse indice index name
?>
<tr>
<td><?php echo $indexname;?><br></td>
</tr>
<?php }?>
</div>
<div class="fr">
<iframe height="780" width="780" scrolling="no" name="fr"></iframe>
</div>
the gtnsegainer.php page on am getting error is
the gtnsegainer page is in iframe
this page retrieve data from database according to the link on the above page
<table class="table" cellspacing="0" width="100%">
<tr>
<td align="left" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9;">Company Name
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">High
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Low
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Last Price
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Prv Close
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Change
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">%Gain
</th>
</tr>
<?php
mysql_connect("localhost","dbname","password");
mysql_select_db("dbname");
$tpnt=$_GET['tpnt'];
$indexname=$_GET['indexname'];
$query="SELECT nsepricequotes_latest.Symbol, nsepricequotes_latest.CompanyName, nsepricequotes_latest.HighPrice, nsepricequotes_latest.LowPrice, nsepricequotes_latest.LastTradedPrice, nsepricequotes_latest.ClosePrice, nsepricequotes_latest.NetChange, nsepricequotes_latest.PercentChange, nse_index_constituents.Tickerplant_index_code
FROM nsepricequotes_latest, nse_index_constituents
WHERE nsepricequotes_latest.TickerPlantCode = nse_index_constituents.TickerPlant_scrip
AND PercentChange >0
ORDER BY PercentChange DESC ";
$result=mysql_query($query);
$query1="Select * from $result where NSE_Index_Name=$indexname";
$result1=mysql_query($query1);
while($row=mysql_fetch_array($result1))
{
$symbol=$row['Symbol'];
$CompanyName=$row['CompanyName'];
$HighPrice=$row['HighPrice'];
$LowPrice=$row['LowPrice'];
$previousclose=$row['LastTradedPrice'];
$ClosePrice=$row['ClosePrice'];
$netChange=$row['NetChange'];
$percentagechange=$row['PercentChange'];
?>
<tr>
<td align="left" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $CompanyName;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $HighPrice;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $LowPrice;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $previousclose; ?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $ClosePrice;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $netChange;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $percentagechange;?></td>
</tr>
<?php } ?>
</table>
it is hard to tell what your error is, in your particular setup, but i recommend adding some simple debugging as such, after each mysql_query($query); add if(mysql_error())die(mysql_error()); and that will point you in the right direction.

Categories