html - PHP Accessing Database through Text Box -


i having problem php code accesses database. when attempt preview page scripts, getting error "unable select database". purpose of code access prayer database (with portion of code) enables edit prayer requests sent in. code in 2 different cgi files. can found below.

first cgi file: approvedenyprayerrequest

<table cellpadding="10"> <tr> <td>first name</td> <td>last name</td> <td>prayer request</td> </tr>  <?php  $username="fbc"; $password="xxxxxxxx"; $database="prayer";  mysql_connect('fbcaltusprayerorg'.ipagemysql.com,$username,$password.prayer); @mysql_select_db($database) or die( "unable select database"); $query="select * request"; $result=mysql_query($query); mysql_close();  while ($row=mysql_fetch_array($result)){ echo ("<tr><td>$row[reg_f_name]</td>"); echo ("<td>$row[reg_l_name]</td>"); echo ("<td>$row[reg_request]</td>"); echo ("<td><a href=\"cgi-bin/prayerrequest.php?id=$row[id]\">edit</a></td></tr>"); } echo "</table>";  ?> 

second cgi file: prayerrequest

<?php  $username="fbc"; $password="xxxxxxxx"; $database="prayer";  mysql_connect('fbcaltusprayerorg.ipagemysql.com',$username,$password); @mysql_select_db($database) or die( "unable select database"); $query = "select * request";  $result = mysql_query($query); $row = mysql_fetch_array($result); ?>  <form method="post" action="cgi-bin/approvedenyprayerrequest.php" />  <table>  <tr> <td>first name:</td> <td><input type="text" name="first" value="<? echo "$row[reg_f_name]" ?>"></td> </tr>  <tr> <td>last name:</td> <td><input type="text" name="last" value="<? echo "$row[reg_l_name]" ?>"></td> </tr>  <tr> <td>prayer request</td> <td><input type="text" name="request" value="<? echo "$row[reg_request]" ?>"></td> </tr>  </table>  </form> 

thanks responses.

looks simple typo quote , misformed string concatenation @ end:

mysql_connect('fbcaltusprayerorg'.ipagemysql.com,$username,$password.prayer); 

should be:

mysql_connect('fbcaltusprayerorg.ipagemysql.com',$username,$password); 

and should switch pdo or mysqli mysql_* functions deprecated.

and if posted real password, should change right away.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -