marcus Posted October 7, 2006 Share Posted October 7, 2006 [code]<?php$ip = $_SERVER[REMOTE_ADDR];echo "<input type=hidden value='$ip'>"; $connection = mysql_connect(localhost,$dbuser,$dbpass; $db = mysql_select_db($dbname, $connection);$query="SELECT * FROM `theme` WHERE `ip`='$ip'";$result44=mysql_query($query);if(mysql_num_rows){echo ":)";}else{$query2 ="INSERT INTO `theme` (`ip` , `theme` ) VALUES ('$ip', '1');";$sql1888 = mysql_query($query2);};?>[/code]it doesnt SQL the information Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/ Share on other sites More sharing options...
AndyB Posted October 7, 2006 Share Posted October 7, 2006 And you got error messages???Remove the [b];[/b] from the closing curly brace.Let's assume that all of the database connection constants are actually known to your code (otherwise it's never going to work).Extend your SQL statements so that you see any error messages ... for example:[code]$sql1888 = mysql_query($query2) or die("Error ". mysql_error(). " with query ". $query2);[/code] Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/#findComment-105510 Share on other sites More sharing options...
marcus Posted October 7, 2006 Author Share Posted October 7, 2006 i'm not getting error messages, it just doesnt wanna sqlnow it just echos the smiley Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/#findComment-105513 Share on other sites More sharing options...
AndyB Posted October 7, 2006 Share Posted October 7, 2006 [quote author=mgallforever link=topic=110795.msg448514#msg448514 date=1160235126]i'm not getting error messages, it just doesnt wanna sql[/quote]"doesnt wanna sql" means what exactly?The code you posted is incomplete. Where are the database connection variables defined?What is the generated html output? Did you add the error trapping that I posted - to both your sql calls? Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/#findComment-105522 Share on other sites More sharing options...
marcus Posted October 7, 2006 Author Share Posted October 7, 2006 i'm not listing my database stuff :oit doesnt want to insert a new row into the databaseyes i did Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/#findComment-105533 Share on other sites More sharing options...
AndyB Posted October 7, 2006 Share Posted October 7, 2006 How much help you get depends entirely on how willing you are to share information and how willing 'we' are to make wild guesses. I don't expect you to actually post your database connection details, but [b]your code[/b] doesn't even show any method of connecting to a database, etc. So perhaps the absence of any database connection variables being defined is why it "doesn't sql anything".If you want to post a more complete version of what you are presently trying to make work, that would be a giant step in the direction of solving your problem. Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/#findComment-105537 Share on other sites More sharing options...
marcus Posted October 7, 2006 Author Share Posted October 7, 2006 i'll show the whole code then :P[code]:)[/code] Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/#findComment-105538 Share on other sites More sharing options...
Orio Posted October 7, 2006 Share Posted October 7, 2006 This has no real meaning:if(mysql_num_rows)I think you mean:if(mysql_num_rows($result44) > 0)Orio. Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/#findComment-105539 Share on other sites More sharing options...
redarrow Posted October 7, 2006 Share Posted October 7, 2006 Also the input field needs a name and how are you posting this information?name? Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/#findComment-105540 Share on other sites More sharing options...
marcus Posted October 7, 2006 Author Share Posted October 7, 2006 Woah, thanks Orio, that works! Thanks alot! Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/#findComment-105541 Share on other sites More sharing options...
redarrow Posted October 7, 2006 Share Posted October 7, 2006 still got no idear about the code theo i have corrected some.?[code]<?php$ip = $_SERVER[REMOTE_ADDR];echo "<input name='ip' type='hidden' value='$ip'>"; $connection = mysql_connect(localhost,neoblob_users,silver101); $db = mysql_select_db(neoblob_users, $connection);$query="SELECT * FROM `theme` WHERE `ip`='$ip'";$result44=mysql_query($query) or die("Error ". mysql_error(). " with query ". $query);if(mysql_num_rows($result44)>0){echo ":";}else{$query2 ="INSERT INTO `theme` (`ip` , `theme` ) VALUES ('$ip', '1');";$sql1888 = mysql_query($query2) or die("Error ". mysql_error(). " with query ". $query2);}?>[/code] Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/#findComment-105542 Share on other sites More sharing options...
AndyB Posted October 7, 2006 Share Posted October 7, 2006 [quote author=mgallforever link=topic=110795.msg448540#msg448540 date=1160238896]i'll show the whole code then :P[code]:)[/code][/quote]Thank you. I'll add you to my list of people who would like help. Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/#findComment-105543 Share on other sites More sharing options...
marcus Posted October 7, 2006 Author Share Posted October 7, 2006 It doesnt post, it's for a theme, once a new user comes to the website they will automatically be inserted into the database w/ their IP and theme, sooner or later they can change this theme, but it's working now, thanks anyway! Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/#findComment-105544 Share on other sites More sharing options...
marcus Posted October 7, 2006 Author Share Posted October 7, 2006 [quote author=AndyB link=topic=110795.msg448545#msg448545 date=1160239395][quote author=mgallforever link=topic=110795.msg448540#msg448540 date=1160238896]i'll show the whole code then :P[code]:)[/code][/quote]Thank you. I'll add you to my list of people who would like help.[/quote]What do you mean, haha, I only edited it. Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/#findComment-105546 Share on other sites More sharing options...
redarrow Posted October 7, 2006 Share Posted October 7, 2006 This is not any good for any website as an ip chages all the time you got to use the members id ok. Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/#findComment-105550 Share on other sites More sharing options...
marcus Posted October 7, 2006 Author Share Posted October 7, 2006 But I've disabled user registration, it's for people who haven't or don't want to register. Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/#findComment-105551 Share on other sites More sharing options...
marcus Posted October 7, 2006 Author Share Posted October 7, 2006 is it possible to do this wtih cookies? Link to comment https://forums.phpfreaks.com/topic/23273-sql-help-needed/#findComment-105555 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.