This topic is locked

Sending data from a table to other table script not working on PHPR 6

12/15/2011 10:56:24 AM
PHPRunner General questions
N
Nelson author

Hi,
I am trying to send some info's from a table to another table..where users can do by clicking on a link similar to this:
http://demo.asprunner.net/metallica777_hotmail_com/Icon_Ads_USA/Contact_advertiser_USA_add.php?send=yes
My script to do the job is inserted into the "View page: before process" (events)



global $conn;

$rstmp = db_query("select Email from Ads USA where USAadsID=".$_REQUEST["editid1"],$conn);

$datatmp = db_fetch_array($rstmp);

$_SESSION["Email"] = $datatmp["Email"];
//

global $conn;

$rstmp = db_query("select Heading from Ads USA where USAadsID=".$_REQUEST["editid1"],$conn);

$datatmp = db_fetch_array($rstmp);

$_SESSION["Heading"] = $datatmp["Heading"];
//

global $conn;

$rstmp = db_query("select USAadsID from Ads USA where USAadsID=".$_REQUEST["editid1"],$conn);

$datatmp = db_fetch_array($rstmp);

$_SESSION["USAadsID"] = $datatmp["USAadsID"];


But I recive an error on the view page as soon as it opens up: http://demo.asprunner.net/metallica777_hotmail_com/Icon_Ads_USA/Ads_USA_view.php?editid1=5
What should I change to fix this please?
Thanks

C
cgphp 12/15/2011

You have to quote tables or fields with spaces in the name:

global $conn;

$rstmp = db_query("select Email from `Ads USA` where USAadsID=".$_REQUEST["editid1"],$conn);

$datatmp = db_fetch_array($rstmp);

$_SESSION["Email"] = $datatmp["Email"];
$rstmp = db_query("select Heading from `Ads USA` where USAadsID=".$_REQUEST["editid1"],$conn);

$datatmp = db_fetch_array($rstmp);

$_SESSION["Heading"] = $datatmp["Heading"];
// The last query is not useful. You can use direct assignment

$_SESSION["USAadsID"] = $_REQUEST["editid1"];
N
Nelson author 12/15/2011



You have to quote tables or fields with spaces in the name:

global $conn;

$rstmp = db_query("select Email from `Ads USA` where USAadsID=".$_REQUEST["editid1"],$conn);

$datatmp = db_fetch_array($rstmp);

$_SESSION["Email"] = $datatmp["Email"];
$rstmp = db_query("select Heading from `Ads USA` where USAadsID=".$_REQUEST["editid1"],$conn);

$datatmp = db_fetch_array($rstmp);

$_SESSION["Heading"] = $datatmp["Heading"];
// The last query is not useful. You can use direct assignment

$_SESSION["USAadsID"] = $_REQUEST["editid1"];



Thanks friend, that solved the problem!