Jump to content

I'm sure you know, click here if you dare!!


karimali831

Recommended Posts

Ok hello,

 

Be great if someone can correct this for me, I'll appreciate it.

 

<?php
$getid = safe_query("SELECT cupID from ".PREFIX."cup_matches");
while($dd = mysql_fetch_array($getid)) $id = $dd['cupID'];

if(is1on1($id)) 

mysql_query("ALTER TABLE `".PREFIX."cup_matches`
        ADD `1on1` INT( 11 ) NOT NULL default '1' AFTER `einspruch`;") 
else
mysql_query("ALTER TABLE `".PREFIX."cup_matches`
        ADD `1on1` INT( 11 ) NOT NULL default '0' AFTER `einspruch`;") 

OR die(PREFIX.'cup_matches <font color="red">failed!</font><br> You have already updated to V4.1.4b!<br />');
echo '<center><h2>Successfully updated to V4.1.4b!</h2><br><a href="index.php"><b>View Site</b></a></center>';
?>

Link to comment
Share on other sites

Not sure what your question is or what kind of error you're getting, but for starters, in both query's, you're terminating before the closing quotes.

mysql_query("ALTER TABLE `".PREFIX."cup_matches` ADD `1on1` INT( 11 ) NOT NULL default '1' AFTER `einspruch`;") else 
mysql_query("ALTER TABLE `".PREFIX."cup_matches` ADD `1on1` INT( 11 ) NOT NULL default '0' AFTER `einspruch`;")

Should be:

...einspruch`"

 

Also, "if" and "elseif" statements need curly brackets:

 

if(something = true) {
...do somehing...
} else {
...do this instead...
}

 

Hope that helps.

Link to comment
Share on other sites

Try this:

<?php
$getid = safe_query("SELECT cupID from ".PREFIX."cup_matches");
while($dd = mysql_fetch_array($getid)) $id = $dd['cupID'];

if(is1on1($id)) {
mysql_query("ALTER TABLE `".PREFIX."cup_matches` ADD `1on1` INT( 11 ) NOT NULL default '1' AFTER `einspruch`"
} else {
mysql_query("ALTER TABLE `".PREFIX."cup_matches` ADD `1on1` INT( 11 ) NOT NULL default '0' AFTER `einspruch`"
}
OR die(PREFIX.'cup_matches <font color="red">failed!</font><br> You have already updated to V4.1.4b!<br />');
echo '<center><h2>Successfully updated to V4.1.4b!</h2><br><a href="index.php"><b>View Site</b></a></center>';
?>

Link to comment
Share on other sites

<?php
$getid = safe_query("SELECT cupID from ".PREFIX."cup_matches");
while($dd = mysql_fetch_array($getid)) $id = $dd['cupID'];

if(is1on1($id)) {
mysql_query("ALTER TABLE `".PREFIX."cup_matches` ADD `1on1` INT( 11 ) NOT NULL default '1' AFTER `einspruch`") ;
} else {
mysql_query("ALTER TABLE `".PREFIX."cup_matches` ADD `1on1` INT( 11 ) NOT NULL default '0' AFTER `einspruch`"); 
}
OR die(PREFIX.'cup_matches <font color="red">failed!</font><br> You have already updated to V4.1.4b!<br />');
echo '<center><h2>Successfully updated to V4.1.4b!</h2><br><a href="index.php"><b>View Site</b></a></center>';
?>

Link to comment
Share on other sites

Not sure what your question is or what kind of error you're getting, but for starters, in both query's, you're terminating before the closing quotes.

mysql_query("ALTER TABLE `".PREFIX."cup_matches` ADD `1on1` INT( 11 ) NOT NULL default '1' AFTER `einspruch`;") else 
mysql_query("ALTER TABLE `".PREFIX."cup_matches` ADD `1on1` INT( 11 ) NOT NULL default '0' AFTER `einspruch`;")

Should be:

...einspruch`"

 

Nope. Because that would mean a syntax error :)

 

mysql_query("ALTER TABLE `".PREFIX."cup_matches` ADD `1on1` INT( 11 ) NOT NULL default '0' AFTER `einspruch`"

 

?!?

 

Also, "if" and "elseif" statements need curly brackets:

 

They don't. But it's best to write 'em.

Link to comment
Share on other sites

havenpets and Karl, there is a problem with both scripts you posted. Syntax error I assume. I tried this:

 

<?php

$getid=safe_query("SELECT cupID FROM ".PREFIX."cup_matches");
$ds=mysql_fetch_array($getid); $cupID = $ds['cupID']; 

$ergebnis2=safe_query("SELECT 1on1 FROM ".PREFIX."cups WHERE ID='$cupID'");
$dl=mysql_fetch_array($ergebnis2);

if($dl['1on1'] ==1) {
mysql_query("ALTER TABLE `".PREFIX."cup_matches`
            ADD `1on1` INT( 11 ) NOT NULL default '1' AFTER `einspruch`;") 

OR die(PREFIX.'cup_matches <font color="red">failed!</font><br> You have already updated to V4.1.4b!<br />'); 
echo '<center><h2>Successfully updated to V4.1.4b!</h2><br><a href="index.php"><b>View Site</b></a></center>';

}else{

mysql_query("ALTER TABLE `".PREFIX."cup_matches`
            ADD `1on1` INT( 11 ) NOT NULL default '0' AFTER `einspruch`;") 

OR die(PREFIX.'cup_matches <font color="red">failed!</font><br> You have already updated to V4.1.4b!<br />'); 
echo '<center><h2>Successfully updated to V4.1.4b!</h2><br><a href="index.php"><b>View Site</b></a></center>';
}
?>

 

No syntax error but adds "1" for each row.

 

I'm trying to add a 1on1 column to my cup_matches table and insert value "1" if ID in the cups table has value "1" in the 1on1 column or insert value "0" if ID in the cups table has value "0" in the 1on1 column. Does that make sense?

 

I believe the mysql_query must be changed? Changing

 

ADD `1on1` INT( 11 ) NOT NULL default '0' AFTER `einspruch`;")

 

to something like

 

ADD `1on1` INT( 11 ) NOT NULL default '$dl['1on1']' AFTER `einspruch`;")

 

make sense .. but won't work.

Link to comment
Share on other sites

I'm trying to add a 1on1 column to my cup_matches table and insert value "1" if ID in the cups table has value "1" in the 1on1 column or insert value "0" if ID in the cups table has value "0" in the 1on1 column. Does that make sense?

Not really.

 

I believe the mysql_query must be changed?

Irrelevant.

 

my question does not make sense or is this rather complicated to do?

The latter.

 

Did I answer your questions? Those were the only questions I found. Did I miss any?

Link to comment
Share on other sites

Neither IMO your db just has a very bad design.

You seem to say peoples db design is always bad? :)

 

Would you be posting any questions on these forums if you had a great application- and db design? Presumably not, as most projects people are working on have a medium difficulty but mostly pick an over-complicated solution probably due to a limited knowledge of the subject domain.

Link to comment
Share on other sites

(See post above and this is the current code:)

 

<?php

$getid=safe_query("SELECT cupID FROM ".PREFIX."cup_matches");
$ds=mysql_fetch_array($getid); $cupID = $ds['cupID']; 

$get1on1=safe_query("SELECT 1on1 FROM ".PREFIX."cups WHERE ID='$cupID'");
$dl=mysql_fetch_array($get1on1);

mysql_query("ALTER TABLE `".PREFIX."cup_matches`
            ADD `1on1` INT( 11 ) NOT NULL default '".$dl['1on1']."' AFTER `einspruch`;")

OR die(PREFIX.'cup_matches <font color="red">failed!</font><br> You have already updated to V4.1.4b!<br />'); 
echo '<center><h2>Successfully updated to V4.1.4b!</h2><br><a href="index.php"><b>View Site</b></a></center>';

?>

 

Problem: Adding incorrect value for added column at cup_matches table. (Adds 1 for all rows)

Column "ID = 1" at _cups table -> 1on1 = 0 so it should add this column with 0 value if ID = 1 and cupID = 1.

ID = cupID

Link to comment
Share on other sites

You need to loop over each of your fetch_arrays() if there are more then one possible hits, and then use a WHERE. Or write an advanced query.

 

That's what I thought but I have no idea how to do this... can you help me do this please using the existing code I posted previously?

I'll appreciate it alot. Been stuck with this for the last few days... and haven't got very far :(

 

Well this is German style, I have no idea what is good and what is bad.. but if it works, it works :)

Link to comment
Share on other sites

You'll probably say this is terrible and laugh but I'm just trying different ways..

 

<?php

$getid=safe_query("SELECT cupID FROM ".PREFIX."cup_matches");
$ds=mysql_fetch_array($getid); $cupID = $ds['cupID']; 

$ergebnis2=safe_query("SELECT 1on1 FROM ".PREFIX."cups WHERE ID='$cupID'");
$dl=mysql_fetch_array($ergebnis2);

if(isset($_GET['action']) && $_GET['action'] == 'alter'){

safe_query("UPDATE ".PREFIX."cup_matches SET 1on1='".$dl['1on1']."' WHERE cupID='$cupID'"); 
echo '<center><h2>Successfully updated to V4.1.4b!</h2><br><a href="index.php"><b>View Site</b></a></center>';

}elseif(!$ds['1on1']) {
mysql_query("ALTER TABLE `".PREFIX."cup_matches`
            ADD `1on1` INT( 11 ) NOT NULL default '1' AFTER `einspruch`;")

OR die(PREFIX.'cup_matches <font color="red">failed!</font><br> You have already updated to V4.1.4b!<br />'); 

redirect('?site=update&action=alter', '<center>Now sorting rows</center>', 0);
}
?>

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.