Please help me with my code Php noob here

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
theoretical_dreamer
Forum Newbie
Posts: 13
Joined: Mon May 22, 2006 12:53 am

Please help me with my code Php noob here

Post by theoretical_dreamer »

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Guys please help me with my syntax, im still familiarizing myself with php ty

Code: Select all

$rs4= mysql_query("SELECT IP4 FROM ipadd ORDER BY IP4")or die(mysql_error()); 
$info4 = (mysql_fetch_array( $rs4 ));
ctr=31;
if (ctr=.$info['IP4'].)
{
	print "The available IP is:".$info4['IP4'].;
}
else
{
	Print "<b>IP4:</b> ".$info4['IP4']. " <br>";
	while($info4 = mysql_fetch_array( $rs4 )) 
	{ 
		
		while (ctr==.$info4['IP4'].)
		{
			ctr++;
			if (ctr!=.$info4['IP4'].)
			{
				print "It works";
			}
		}
	
	Print "<b>IP4:</b> ".$info4['IP4'] . " <br>";
	}
}
Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

Your missing the dollar sign before the ctr
theoretical_dreamer
Forum Newbie
Posts: 13
Joined: Mon May 22, 2006 12:53 am

Post by theoretical_dreamer »

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Thanks bro, but there is still no output please check my code:

Code: Select all

$rs4= mysql_query("SELECT IP4 FROM ipadd ORDER BY IP4")or die(mysql_error()); 
$info4 = (mysql_fetch_array( $rs4 ));
$ctr=31;

if ($ctr=.$info['IP4'].)
{
	print "The available IP is:".$info4['IP4'].;
}
else
{
	Print "<b>IP4:</b> ".$info4['IP4']. " <br>";
	
	while($info4 = mysql_fetch_array( $rs4 )) 

	{ 
		
		while ($ctr==.$info4['IP4'].)
		{
			$ctr++;
			if ($ctr!=.$info4['IP4'].)
			{
				print "It works";
			}
		}
		
	Print "<b>IP4:</b> ".$info4['IP4'] . " <br>";
	}
}
Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Extremest
Forum Commoner
Posts: 84
Joined: Mon Aug 29, 2005 12:39 pm

Post by Extremest »

I am not very good but it does seem that you are trying to use the result array as an assoc array and it should not be retrieving it that way...use mysql_fetch_assoc.
User avatar
neogeek
Forum Newbie
Posts: 24
Joined: Sun May 14, 2006 4:24 am

Post by neogeek »

Not sure if I found the problem, but try this code:

Code: Select all

<?php

$rs4= mysql_query("SELECT IP4 FROM ipadd ORDER BY IP4")or die(mysql_error());
$info4 = (mysql_fetch_array( $rs4 ));
$ctr=31;

if ($ctr==$info4['IP4'])
{
        print "The available IP is:" . $info4['IP4'];
}
else
{
        Print "<b>IP4:</b> ".$info4['IP4']." <br>";

        while($info4 = mysql_fetch_array( $rs4 ))

        {

                while ($ctr==$info4['IP4'])
                {
                        $ctr++;
                        if ($ctr!=$info4['IP4'])
                        {
                                print "It works";
                        }
                }

        Print "<b>IP4:</b> ".$info4['IP4']." <br>";
        }
}

?>
Edited: Added fix found by Flamie.
Last edited by neogeek on Wed May 24, 2006 4:35 am, edited 1 time in total.
Flamie
Forum Contributor
Posts: 166
Joined: Mon Mar 01, 2004 3:19 pm

Post by Flamie »

your very 1st if has $info['IP4'] shouldnt it be $info4?
Post Reply