Jump to content

cilian29

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

cilian29's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. good day thank you for all helping me and for the replies on seeing the code you suggested I immediately tried adding the changes but unfortunately I came upon one problem to the next so here it goes and I made some difference on my previous script above. Parse error: parse error, unexpected T_LOGICAL_OR in C:\Program Files\xampp\htdocs\preprod\overwriteB.php on line 40 im getting this error when the code is inserted so i comment it out for a while. or die(pg_last_error()); /* Don't comment out the "or die" - you need it to find the bug */ Warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near ")" at character 35 in C:\Program Files\xampp\htdocs\preprod\sample.php on line 39 Warning: pg_fetch_array() expects parameter 1 to be resource, boolean given in C:\Program Files\xampp\htdocs\preprod\sample.php on line 41 1 <?php 2 include('server/configA.php'); 3 4 $mod = $_GET[mod]; 5 $myid =$_GET[id]; 6 7 $link=pg_connect("host= " .DB_HOST. " port= " .DB_PORT. " dbname= " .DB_DATABASE. " user= " .DB_USER. " password= " .DB_PSWD); 8 if(!$link) 9 { 10 die('Failed to connect to server: ' .pg_result_error_field($link)); 11 } 12 callme($myid); /* Don't put "$" in front of callme */ 13 if($_REQUEST[nir]==1){callme();} 14 15 16 17 18 $sq1 ="SELECT * FROM merchantable"; 19 $result =pg_query($sq1); 20 21 //for refid display below 22 while ($row = pg_fetch_array($result)){ 23 echo '<table>'; 24 echo '<tr>'; 25 26 27 echo "<td><a href='?mod=$mod&nir=1&id=$myid& $row[empid]'>".$row["empid"]."</a></td>"; 28 29 echo '</tr>'; 30 echo '</table>'; 31 } 32 33 34 35 function callme($myid){ 36 37 $q1 =" SELECT * FROM nir WHERE empid = ($myid)"; 38 //$q1 ="SELECT * FROM nir"; 39 $result =pg_query($q1); 40 //or die(pg_last_error()); /* Don't comment out the "or die" - you need it to find the bug */ 41 42 43 while($rows=pg_fetch_array($result)){ /* Use pg_fetch_array() on $result, not on $q1 */ 44 45 echo $rows[empid]; 46 } 47 } 48 ?> thank you again hope you van help me... pls!
  2. Thank you for your quick reply and I hope you help me further when you mention pass the callme($myid) as an argument heres what I did. I just added the call me above my original function. I created anew php file to test on it sample.php $callme($myid); function callme($myid){ $sql2 =" SELECT * FROM employee WHERE empid = ($myid)"; $result=pg_query($sql2); //or die(pg_last_error()); while($row=pg_fetch_array($sql2)){ echo $row[empid]; } } my question is, do I remove my switch case when I call the function? when I run the my code above this time I dont see any errors but there is no display on my browser and my url: http://localhost/preprod/sample.php?mod=&nir=1&id=&%201004SA>1004SA</a></td><table><tr><td><a%20href=http://localhost/preprod/sample.php?mod=&num=1&id=&%201004SA>1004SA</a></td><table><tr><td><a%20href=
  3. hi all I'm trying to make this work, can you help on my script i'm doing now I'm trying to call my php link within functions. pls bear with me bec. I'm lost my my self. im trying to call a list of items from my database when I clicked the employee nos.by the way I'm using posrgesql and apache server and its running good. I'm getting this error Warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near ")" at character 44 in C:\Program Files\sample.php Warning: pg_fetch_array() expects parameter 1 to be resource, string given in C:\Program Files\sample.php I have a query function called function callme(){ $sql2 =" SELECT * FROM employee WHERE empid = ($myid)"; $result=pg_query($sql2); //or die(pg_last_error()); while($row=pg_fetch_array($sql2)){ echo $row[empid]; } Then I create a swich case to call my function switch($_REQUEST["num"]) { case "1": callme(); break; case "2": echo 'no record!!'; break; default: break; } } this is my php file: $mod = $_GET[mod]; $myid =$_GET[id]; $sq1=pg_query("SELECT DISTINCT empid FROM employee INNER JOIN client c ON(merchantable.ccindex = c.clientindex) ORDER BY merindex ASC"); :shy:this code is running its showing me what distinct items i need. while ($row = pg_fetch_array($sq1)){ echo '<table>'; echo '<tr>'; echo "<td><a href='?mod=$mod&num=1&id=$myid& $row[refid]>".$row["refid"]."</a></td>"; echo "</tr>"; echo '</table>'; } then my url :http://localhost/preprod/overwriteA.php?mod=&num=1&id=&%201004SA%3E1004SA%3C/a%3E%3C/td%3E%3Ctable%3E%3Ctr%3E%3Ctd%3E%3Ca%20href= Why am I not getting anywhere PLEase HELp
  4. Ok no problem got it solved on my own
  5. Good Day! I'm starting to learn postgresql using php and right now I'm stuck being a newbie I have limitted understanding if my query is right. I'm trying to copy all from table1(columnA) and paste all on table2(columnA) using pgadmin iii. I noticed that this cannot be done or I really dont know what I'm doing. so I tried insert into query INSERT INTO table2(columnA, columnB) VALUES (table1.columnA, table2.columnB) I then follow this with my php code: $sql ="SELECT * FROM table1"; $result = pg_query($dbconn, $sql); while($row =pg_fetch_array($result)){ $sql2="INSERT INTO table2(columnA, columnB) VALUES ($row[columnA], $row[columnB])"; $result=pg_query($sql2); echo $row[columnA]."<br>"; echo $row[columnB]."<br>"; unfortunately I'm not getting results or error. the last error I got is pg_query is not good resource for postgresql. can anyone shed light cuz I'm pulling my hair for days now. thanks in advance.
×
×
  • 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.