Jump to content

Recommended Posts

lol,

 

i had this same problem a while ago i have a line here:

  		$sql= "INSERT*INTO users(`id`,`displayname`,`username`,`password`, `email`,`usercode`,`status`,`date`,`ip`) VALUES("'0','$displayname','$username','$password','0','$usercode','.$status.','$date','$ip')";

 

the difficulty is some of the fields in the database i want to leave untouched for now. as for the values, i want them to match, i tried googling it but im pretty sure i couldnt find the right keywords. lol.

 

thanks guys

 

HoTDaWg

Link to comment
https://forums.phpfreaks.com/topic/42067-disappointing-question/
Share on other sites

here try this, i just cleaned it up, a lot:

 

$sql = "INSERT INTO `users` (`id`,`displayname`,`username`,`password`, `email`,`usercode`,`status`,`date`,`ip`) VALUES ('0', '{$displayname}', '{$username}', '{$password}', '0', '{$usercode}', '{$status}', '{$date}', '{$ip}')";

mysql_query($sql) or die("Error: ".mysql_error());

I don't think I understand your question at all.  INSERT adds a record to the database. INSERT * should generate a syntax error. If id is meant to be a record id, then where do you expect record zero to get stored?

 

Humour me and rephrase your question (preferably with an explanation).

you dont need to insert somthink that not there do you if you do then you use defualt in phpmyadmin ok

 

<?php

$sql = "INSERT INTO `users` (`id`,`displayname`,`username`,`password`, `email`,`usercode`,`status`,`date`,`ip`) VALUES (' ', '$displayname', '$username', '$password', ' ', '$usercode', '$status', '$date', '$ip')";

$result=mysql_query($sql);
?>

There's still something fishy about the question.  You don't INSERT into a specific row. INSERT inserts a whole new row wherever MySQL wants it to go - with a unique id, but not necessarily in a specific row position (usually at the end, except when rows have been previously deleted).  If you want to change data in a specific row, then UPDATE with a WHERE condition is the way to go.

sorry for wasting your time guys, it was pretty late last nightaand my mind wasnt working. Basically, I want to create a new row that is why i am using the insert statement. The problem is, i do not have variables or anything to insert for certain columns such as id or password. Now, I understand that if it is auto incremement i dont have to worry much bout it but as for the email column, I want no information to be inserted into it now. How do i tell it, leave that specific column untouched? thanks guys.

 

 

HoTDaWg

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.