|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
database horror
I finally got my database to work ..
members can join and are numbered from 1 and on. but ... because it is autoincrement in the database ... if a person is deleted, there is no way to get that certain number back. I have a join that somehow was entered into the database without any user name or pass. So ... I tried to put it into the database ... but ... I failed ... there is a login_temp, login, and user_tran .... I was able to put info for this person in all of these except the login temp. the person is number 13. I joined someone after them which means they would be 14. I looked in mysql and it will not compute this right ... this means that money, payouts, and numbering of people will be influenced incorrectly because of it. Can anyone please tell me how to adjust the number or names correctly without messing things up ... I really hope I explained this right ... if you want to take a look at my database ... please let me know ... I am definitely in a real pickle ... I think ???? Thank you all at codewalkers, Sandy |
|
#2
|
|||
|
|||
|
RE: database horror
As far as I understand the problem, this is caused by the index of the table. As soon as someone enters a new ID, the cardinality of the index is increased, which means when the last cardinality was 13, SQL creates a new entry with ID 14. If you now delete entry 13, the cardinality is not changed, and a new entry will be created anyway.
Possible solution: If you have the entries to be deleted all at the end of your table (eg. Entries 91-102 out of 102), just delete the entries and, if the cardinality remains unchanged (you can see the cardinality of a table in the Table Structure area of PHPMyAdmin), just delete the index and create it new (the cardinality should then be set to the highest value of the indexed field). If you have entries to be deleted distributed all over your table, there are only two solutions: either just continue with new values, keeping the "holes" in the indexed field, or, if you do not have any other table joining the user-table's ID-field, just write a short script which reads all entries from the table, kills the table, re-creates it and inserts the values, but without the ID. Then SQL will create the indexed field without holes. I hope this can tackle your problem a little... |
|
#3
|
|||
|
|||
|
RE: database horror
Hi mastamind,
thank you for your reply ... it is much appreciated! I have not been able to cure this ... I am new and have been learning quickly ... but ... I guess this is probably so simple it is over my head ...lol Maybe you can help me with this: I have a piece of script within the same database and code that gives me this error: Code:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/adminrm/public_html/newadmin/letter.php on line 106 Can you give me any idea why or where to look to fix this ... here is the code: Code:
<?
include("connect.php");
if($del==1)
{
$query="delete from letter where srno='$srno'";
$result=mysql_query($query,$db);
$edit=0;
}
if($Submit=="Add Letter")
{
if($subject=="")
{
$msg.="Please fill in the Subject.<br>";
}
if($letter=="")
{
$msg.="Please fill in the Letter.<br>";
}
if($msg=="")
{
$date=date("d/m/Y");
$query="insert into letter(subject,letter,ondate) VALUES('$subject','$letter','$date')";
$result=mysql_query($query,$db);
if($result)
{
$edit=0;
$msg="Letter Added Successfully.";
}
else
{
$msg="There is some error in the query.Please contact to server administrator";
}
}
}
if($Submit1=="Save Letter")
{
if($subject=="")
{
$msg.="Please fill in the Subject.<br>";
}
if($letter=="")
{
$msg.="Please fill in the Letter.<br>";
}
if($msg=="")
{
$query="update letter set subject='$subject',letter='$letter' where srno=$srno";
$result=mysql_query($query,$db);
if($result)
{
$msg="Letter Updated Successfully.";
}
else
{
$msg="There is some error in the query.Please contact to server administrator";
}
}
}
?>
<table width="100%" border="0" height="82">
<tr>
<td bgcolor="#4883E4">
<div align="center"><font color="#FFFFFF"><b>Letter Management</b></font></div>
</td>
</tr>
<?
if($msg!="")
{
echo "<div align='center'><font color='red' size='2'><b>".$msg."</b></font></div>";
}
?>
<tr>
<td>
<div align="center">
<table width="80%" border="0" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td width="23%">
<div align="center"><b>Letter Number</b></div>
</td>
<td width="23%">
<div align="center"><b>Subject</b></div>
</td>
<td width="23%">
<div align="center"><b>Date</b></div>
</td>
<td width="14%">
<div align="center"><b> </b></div>
</td>
<td width="17%">
<div align="center"><b> </b></div>
</td>
</tr>
<?
$query="select * from letter";
$result=mysql_query($query,$db);
$total=mysql_num_rows($result);
for($i=0;$i<$total;$i++)
{
$row=mysql_fetch_array($result);
?>
<tr>
<td width="23%">
<div align="center"><b><?echo $row["srno"];?></b></div>
</td>
<td width="23%">
<div align="center"><b><?echo $row["subject"];?></b></div>
</td>
<td width="23%">
<div align="center"><b><?echo $row["ondate"];?></b></div>
</td>
<td width="14%">
<div align="center"><b><a href="letter.php?srno=<?echo $row["srno"];?>&edit=1">Edit</a></b></div>
</td>
<td width="17%">
<div align="center"><b><a href="letter.php?srno=<?echo $row["srno"];?>&del=1">Delete</a></b></div>
</td>
</tr>
<?
}
if($total<1)
{
echo "<tr><td colspan='5' align='center'><b><font color='red'>No Letter In List</font></b></td></tr>";
}
?>
</table>
</div>
</td>
</tr>
</table>
<table width="100%" border="0" height="82">
<tr>
<td bgcolor="#4883E4">
<div align="center"><font color="#FFFFFF"><b>
<?
if($edit)
echo "Edit Letter";
else
echo "Add New Letter";
?>
</b></font></div>
</td>
</tr>
<tr>
<td>
<?
if($edit)
{
$query="select * from letter where srno='$srno'";
$result=mysql_query($query,$db);
$row=mysql_fetch_array($result);
}
?>
<div align="left"><br>
<font color="#FF0000"><b>Note: </b></font><br>
IF you want to Show the Referral URL in any letter, then Just use "<font color="#FF0000"><b>@@URL</b></font>"
where ever you want the Referral Link.<br>
Dynamically, That Link will be replaced by respective users referral link
who use that email sample. </div>
<form name="form1" method="post" action="">
<table width="67%" border="0" cellpadding="0" cellspacing="0" bordercolor="#000000" align="center">
<tr>
<td width="27%" height="2">
<div align="center"><b><br>
Subject:</b>
<?
if($edit)
{
?>
<input type="text" name="subject" value="<?echo $row["subject"];?>">
<input type="hidden" name="srno" value="<?echo $srno;?>">
<?
}
else
{
?>
<input type="text" name="subject">
<?
}
?>
</div>
</td>
</tr>
<tr>
<td width="27%" height="22" valign="middle" align="center">
<div align="center"><br>
<?
if($edit)
{
?>
<textarea name="letter" cols="50" rows="20"><?echo $row["letter"];?></textarea>
<?
}
else
{
?>
<textarea name="letter" cols="50" rows="20"></textarea>
<?
}
?>
</div>
</td>
</tr>
<tr>
<td width="27%" height="22">
<div align="center"><br>
<?
if($edit)
{
?>
<input type="hidden" name="edit" value="0">
<input type="submit" name="Submit1" value="Save Letter">
<?
}
else
{
?>
<input type="submit" name="Submit" value="Add Letter">
<?
}
?>
</div>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
Any help would be appreciated ... :Wink: thank you again! Sandy |
|
#4
|
|||
|
|||
|
RE: database horror
Here are lines 104-106:
I would turn that into: $query="select * from letter"; $result=mysql_query($query,$db); if(!$result) { echo mysql_error(); die; } $total=mysql_num_rows($result); Now, that should give you an error message...let us see what that error is and we will go from there.. |
|
#5
|
|||
|
|||
|
RE: database horror
Hello Matt ...
here is the error: Code:
Parse error: parse error in /home/adminrm/public_html/newadmin/letter.php on line 130 thank you .... Sandy |
|
#6
|
|||
|
|||
|
RE: database horror
Did you change anything else? That isn't the error I was looking for....please post lines 100-130.
|
|
#7
|
|||
|
|||
|
RE: database horror
Hi Matt ...
no ... I did not change anything else that I can remember ... but ... here are lines 100 -130 Code:
<div align="center"><b> </b></div>
</td>
</tr>
<?
$query="select * from letter";
$result=mysql_query($query,$db);
if(!$result) {
echo mysql_error();
die;
}
$total=mysql_num_rows($result);
?>
<tr>
<td width="23%">
<div align="center"><b><?echo $row["srno"];?></b></div>
</td>
<td width="23%">
<div align="center"><b><?echo $row["subject"];?></b></div>
</td>
<td width="23%">
<div align="center"><b><?echo $row["ondate"];?></b></div>
</td>
<td width="14%">
<div align="center"><b><a href="letter.php?srno=<?echo $row["srno"];?>&edit=1">Edit</a></b></div>
</td>
<td width="17%">
<div align="center"><b><a href="letter.php?srno=<?echo $row["srno"];?>&del=1">Delete</a></b></div>
</td>
</tr>
<?
}
Thanks ... Sandy |
|
#8
|
|||
|
|||
|
RE: database horror
Looks like you lost a couple of lines along the way...
for($i=0;$i<$total;$i++) { $row=mysql_fetch_array($result); should come after: $total=mysql_num_rows($result); |
|
#9
|
|||
|
|||
|
RE: database horror
Well ... Matt ...
that was perfect ... except ... shamefully ... this is the error I got now: Code:
Table 'adminrm_recycled.letter' doesn't exist I've played with databases, but have not yet made any on my own ... can you tell me where to start ... and, I will pick up on this fast .... I am a very quick learner ... :uhoh: Thank you so much! Sandy |
|
#10
|
|||
|
|||
|
RE: database horror
I am guessing that you are buying hosting at a hosting company? Do they give you access to phpmyadmin? If so, you can create tables in there...
|
|
#11
|
|||
|
|||
|
RE: database horror
Yes ... Matt ...
this is how I've been learning ... I have a really great CPanel with my hosting company. I practice all of time with databases that are already done ... but ... now ... I have this site that is was suppose to launch months ago and I've failed ... I paid a programmer $200.00 to get this up ... but ... this is as far as it went ... that is ok because I want to learn ... so where do we go from here? Sandy |
|
#12
|
|||
|
|||
|
RE: database horror
Well..head into phpmyadmin and create a table with the columns you need. You should be able to tell what columns you need by looking through that code and finding variables such as:
$row["subject"] the part between the quotes (subject) is the name of a column in that table. So, create a table with all those columns and go from there.... |
|
#13
|
|||
|
|||
|
RE: database horror
OK ... I try right now ...
:eek: Sandy |
|
#14
|
|||
|
|||
|
RE: database horror
Hey .. Matt ... this is what I got ...
Code:
SQL-query : CREATE TABLE `letter` ( `snro` VARCHAR NOT NULL , `subject` VARCHAR NOT NULL , `letter` VARCHAR NOT NULL , `ondate` VARCHAR( 00 - 00 - 0000 ) NOT NULL ) the system said I made an sql error Sandy |
|
#15
|
|||
|
|||