Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
La página aparece en blanco después de compilar PHP y PostgreSQL

Problema

Tengo un problema al mostrar la página después de compilar este código, pero no puedo ver qué es lo que está mal y no puedo depurar porque no aparece en la web.

Código PHP y PostgreSQL:

 <?php // Connecting, selecting database $dbconn = pg_connect("host=***** port=***** dbname=***** user=***** password=*****") or die('Could not connect: ' . pg_last_error()); //collect if(isset($_POST['search'])) { $searchq = $_POST['search']; $searchq = preg_replace("#[^0-9a-z]#i"."".$searchq); // Performing SQL query $query = "SELECT * FROM enumbers WHERE code LIKE '%$searchq%'") or die ("could not search!"); $result = query($query); if($result = 0){ $output = 'There is no such E-Number!' }else{ while($row = mysql_fetch_array($query)) { $code = $row['code']; $name = $row['name']; $type = $row['type']; $vegan = $row['vegan']; $output .= '<div> '.vegan.' '; } } } ?>

El formulario y el código de impresión:

 <div id="tablebox"> <!-- Search bar --> <p>Is It Vegan?</p> <form name="form1" method="post" action="searchEnumbers.php"> <input name="search" type="text" size="30" maxlength="5" /> <input name="submit" type="submit" value="Search" /> </form> <?php print("$output"); ?> </div>

Actualizar

Creo que el problema podría ser que estoy usando algún código MySQL, pero no puedo decir si lo estoy.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Está utilizando mysql_fetch_array en lugar del método postgres. Por favor vea la muestra

 <?php // Connecting, selecting database $dbconn = pg_connect("host=**** port=**** dbname=**** user=**** password=****") or die('Could not connect: ' . pg_last_error()); $output = ''; //collect if(isset($_POST['search'])) { $searchq = $_POST['search']; // $searchq = preg_replace("#[^0-9a-z]#i"."".$searchq); // Performing SQL query $query = "SELECT * FROM enumbers WHERE code LIKE '%$searchq%'"; $ret = pg_query($dbconn, $query); if(!$ret){ echo pg_last_error($dbconn); exit; } $output = ''; while($row = pg_fetch_assoc($ret)){ $code = $row['code']; print_r($row); $name = $row['name']; $type = $row['type']; $vegan = $row['vegan']; $output .= '<div> '.vegan.' '; } } echo "Operation done successfully\n"; pg_close($dbconn); ?>
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!