Page 1 of 1

Please help me with my code Php noob here

Posted: Tue May 23, 2006 8:42 pm
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]

Posted: Tue May 23, 2006 8:44 pm
by GeXus
Your missing the dollar sign before the ctr

Posted: Tue May 23, 2006 9:32 pm
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]

Posted: Wed May 24, 2006 12:36 am
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.

Posted: Wed May 24, 2006 12:37 am
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.

Posted: Wed May 24, 2006 12:44 am
by Flamie
your very 1st if has $info['IP4'] shouldnt it be $info4?