NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page a little help debugging some small code (php)

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-16-2006, 10:23 AM THREAD STARTER               #1 (permalink)
NamePros Regular
 
edmarriner's Avatar
Join Date: Apr 2005
Location: England :D
Posts: 834
edmarriner is a jewel in the roughedmarriner is a jewel in the roughedmarriner is a jewel in the rough
 



a little help debugging some small code (php)


hi,

Just a simple bit of code but its a bit mucked up.
Im just getting a blank page - no errors.

PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body bgcolor="#00FF00">
<?php
$username
="root";
$password="********";
$database="msn";

$firstn=$_POST['first'];
$lastn=$_POST['last'];
$msn=$_POST['msn'];
????: NamePros.com http://www.namepros.com/programming/228295-little-help-debugging-some-small-code.html
$class=$_POST['class'];

if(
$do == "insert"{
????: NamePros.com http://www.namepros.com/showthread.php?t=228295

mysql_connect(localhost,$username,$password);
@
mysql_select_db($database) or die( "Unable to select database");

$query "INSERT INTO `addys` (`firstn`, `lastn`, `msn`, `class`) VALUES ('$firstn', '$lastn', '$email', '$class')";

$result=mysql_query($query);
if(!
$result){
echo
"error, data nt submitted";
}
mysql_close();
}elseif(
$do == "form"){
echo
"<table width='100%' border='0' cellpadding='0' cellspacing='0'>
  <tr>
    <td><form id='form1' name='form1' method='post' action='index.php?do=insert'>

      <div align='right'>: first name : </div>
      <label>
      <div align='right'>
        <input type='text' name='firstn' />
      </div>
      </label>
      <div align='right'><br />
        : last name : </div>
      <label>
      <div align='right'>
        <input type='text' name='lastn' />
      </div>
      </label>
      <div align='right'><br />
        : msn address : </div>
      <label>
      <div align='right'>
        <input type='text' name='msn' />
      </div>
      </label>
      <div align='right'><br />
        : class  : </div>
      <label>
      <div align='right'>
        <input type='text' name='class' />
      </div>
      </label>
      <p align='right'>
        <label>
        <input type='submit' name='Submit' value='Submit' />
        </label>
      </p>
    </form></td>
  </tr>
</table>"
;
}else{

mysql_connect(localhost,$username,$password);
@
mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM msn";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

echo 
"<b><center>Database Output</center></b><br><br>";

$i=0;
while (
$i $num) {

$firstname=mysql_result($result,$i,"first");
$lastname=mysql_result($result,$i,"last");
$email=mysql_result($result,$i,"msn");
$classname=mysql_result($result,$i,"class");

echo 
"<b>$firstname $lastname</b><br>addy: $msn<br>class: $classname<br><hr><br>";

$i++;
}
}
?></body>
</html>
Can anyone help?


cheers,

-ed
__________________
Leeds united football club


edmarriner is offline  
Old 08-16-2006, 12:48 PM   #2 (permalink)
NamePros Member
Join Date: May 2006
Posts: 160
TwistMyArm is on a distinguished road
 



For starters, I'd say you need to fix:
if($do == "insert"{

Make it:
if($do == "insert"){

I would hazard a guess and say that you should have been getting errors... maybe error reporting is turned off?
TwistMyArm is offline  
Old 08-17-2006, 08:20 AM THREAD STARTER               #3 (permalink)
NamePros Regular
 
edmarriner's Avatar
Join Date: Apr 2005
Location: England :D
Posts: 834
edmarriner is a jewel in the roughedmarriner is a jewel in the roughedmarriner is a jewel in the rough
 



Hi,

Cheers TwistMyArm, i didnt see that , its all working now

thanks,

added rep;

-ed
__________________
Leeds united football club


edmarriner is offline  
Old 08-17-2006, 11:06 AM THREAD STARTER               #4 (permalink)
NamePros Regular
 
edmarriner's Avatar
Join Date: Apr 2005
Location: England :D
Posts: 834
edmarriner is a jewel in the roughedmarriner is a jewel in the roughedmarriner is a jewel in the rough
 



--

Could i ask for a little more help please with this search code

PHP Code:
if($searchresults){
????: NamePros.com http://www.namepros.com/showthread.php?t=228295
                
mysql_connect(localhost,$username,$password);
                @
mysql_select_db($database) or die( "Unable to select database");
                
$term $_POST['term'];
                
$search_term_esc AddSlashes($term); 
            
$query "SELECT * FROM addys WHERE firstn, lastn, msn, class LIKE '%$search_term_esc%'";
                
$result=mysql_query($query);
                
                
$num=mysql_numrows($result);
                
                
mysql_close();
                
                echo 
"<b><center>Search Results</center></b><br><br>";
                
                
$i=0;
                while (
$i $num) {
????: NamePros.com http://www.namepros.com/showthread.php?t=228295
                
                
$one=mysql_result($result,$i,"firstn");
                
$two=mysql_result($result,$i,"lastn");
                
$three=mysql_result($result,$i,"msn");
                
$four=mysql_result($result,$i,"class");
                
                echo 
"<b>$one $two</b><br>addy: $three<br>school: $four<br><hr><br>";
                
                
$i++;
                echo
"1";
                }
    }else{
    echo
"<form id='form1' name='form1' method='post' action='index.php?do=search'>
  <label>
  <input type='text' name='term' />
  </label>
  <label>
  <input type='submit' name='searchresults' value='search' />
  </label>
</form>"
;
}
///////////////////////////////////////////////////////////////////////////////////////////////
}elseif($do ............. 
its not returning any results

any ideas?

thanks,

-ed
__________________
Leeds united football club


edmarriner is offline  
Old 08-17-2006, 02:34 PM   #5 (permalink)
Domains my Dominion
 
sdsinc's Avatar
Join Date: Aug 2005
Location: Web 1.0
Posts: 9,558
sdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatness
 


Third World Education Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Animal Rescue Animal Cruelty AIDS/HIV Animal Rescue Wildlife Breast Cancer Animal Rescue Wildlife
You need a query like this:
Quote:
$query = "SELECT * FROM addys
WHERE firstn LIKE '%$search_term_esc%'
OR lastn LIKE '%$search_term_esc%'
OR msn LIKE '%$search_term_esc%'
OR class LIKE '%$search_term_esc%'
__________________
NameNewsletter.com - free lists of available domain names
ZoneFiles.net (beta) - ccTLD and gTLD droplists
sdsinc is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 12:08 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger