theoretical_dreamer Posted May 24, 2006 Share Posted May 24, 2006 need help regarding syntax please check my code tnx$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>"; }} Quote Link to comment https://forums.phpfreaks.com/topic/10307-php-noob-here-need-help/ Share on other sites More sharing options...
AndyB Posted May 24, 2006 Share Posted May 24, 2006 Don't forget to tell us what errors you get and identify the lines in your code. php provides really useful error messages that (with a little practice) lead you to the trouble spots.Most of your problems stem from mis-use of the . concatenation operator (which is used exclusively for adding strings to make longer strings. Note also the equality check operator is ==. So, for example:[code]if (ctr=.$info['IP4'].){print "The available IP is:".$info4['IP4'].;[/code]Should be:[code]if (ctr==$info['IP4']){print "The available IP is: ".$info4['IP4'];[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10307-php-noob-here-need-help/#findComment-38437 Share on other sites More sharing options...
kenrbnsn Posted May 24, 2006 Share Posted May 24, 2006 Your souce is filled with syntax errors. For starters:[list][*]The comparision operator for equality is the double equal "==" not the single equal "="[*]The period is the string concatenation operator, code like [code]<?php if (ctr=.$info['IP4'].) ?>[/code] is completely meaningless. What were you trying to write?[/list]Your code written syntactally correct would look something like this: (whether it's logically correct is another question)[code]<?php$rs4= mysql_query("SELECT IP4 FROM ipadd ORDER BY IP4")or die(mysql_error());$ctr=31; // need a $ infront of the variable and since it doesn't change, move it out of the loopwhile ($info4 = mysql_fetch_assoc( $rs4 )) { // make this a "while" loop if (ctr == $info['IP4']) print "The available IP is:".$info4['IP4']; else print "<b>IP4:</b> ".$info4['IP4']. " <br>"; while ($ctr == $info4['IP4']) { $ctr++; if ($ctr != $info4['IP4']) print "It works"; } Print "<b>IP4:</b> ".$info4['IP4'] . " <br>";}?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/10307-php-noob-here-need-help/#findComment-38441 Share on other sites More sharing options...
theoretical_dreamer Posted May 24, 2006 Author Share Posted May 24, 2006 tnx for the rply that really help Quote Link to comment https://forums.phpfreaks.com/topic/10307-php-noob-here-need-help/#findComment-38442 Share on other sites More sharing options...
theoretical_dreamer Posted May 24, 2006 Author Share Posted May 24, 2006 guys i did wat u said but it still didn't work here's my edited code $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'].) //if ctr is equal to the 1st value of IP4 field in the database{ 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>"; }} Quote Link to comment https://forums.phpfreaks.com/topic/10307-php-noob-here-need-help/#findComment-38445 Share on other sites More sharing options...
AndyB Posted May 24, 2006 Share Posted May 24, 2006 No, No, No. You didn't do what we said. You didn't post what the errors were. You didn't identify which lines the errors occurred at. Change this:[code]if ($ctr=.$info['IP4'].) //if ctr is equal to the 1st value of IP4 field in the database{print "The available IP is:".$info4['IP4'].;[/code]To this (again, carefully please) and try again.[code]if ($ctr==$info['IP4']); //if ctr is equal to the 1st value of IP4 field in the database{print "The available IP is: ".$info4['IP4'];[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10307-php-noob-here-need-help/#findComment-38448 Share on other sites More sharing options...
theoretical_dreamer Posted May 24, 2006 Author Share Posted May 24, 2006 oh sorry... i forgot to turned the error report message in apache, thanks bro Quote Link to comment https://forums.phpfreaks.com/topic/10307-php-noob-here-need-help/#findComment-38450 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.