Jump to content

SQL Help needed


marcus

Recommended Posts

[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
Share on other sites

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
Share on other sites

[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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

[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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.