CodingA database for my data

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  ANT_THOMAS   
 To:  ALL
35356.89 
PHP code:
$editnews =MYSQL_QUERY("UPDATE nmr SET code='$code',labbookref='$labbookref',contents='$contents',solvent='$solvent',elements='$elements',servercode='$servercode',time='$time',machine='$machine',year='$year',month='$month',nmre1='$nmre1',nmrn1='$nmrn1',nmre2='$nmre2',nmrn2='$nmrn2',nmre3='$nmre3',nmrn3='$nmrn3',nmre4='$nmre4',nmrn4='$nmrn4',nmre5='$nmre5',nmrn5='$nmrn5' WHERE id='$id' ");
 


What's wrong with this?

It's pulling the data from a form but doesn't actually update the entry, doesn't chuck out an error either.

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS      
35356.90 In reply to 35356.89 
Echo the statement and try running it directly in mysql - you might see/get an error then?

Is Id a varchar or integer?
0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  Peter (BOUGHTONP)     
35356.91 In reply to 35356.90 

Id is mediumint(5).

 

Just tried echoing it and it doesn't seem to echo $id which is odd.

 

Actually, I may know why.


0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  ALL
35356.92 

Right, id issue sorted, when I echo it and run it directly in mysql (phpmyadmin) it works fine, no errors, and the database updates as expected.

 

:@


0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  ALL
35356.93 
Ok, it's working now, seems it was my id issue. Yay, done.

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS      
35356.94 In reply to 35356.92 
You probably want something like:
code:
if ( ! isNumeric($id) ){ throwError('Invalid id supplied'); }


Just before the query.

That way, next time you have null/blank/other in Id you don't get an apparent success whilst nothing actually happens... :)
0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  ALL
35356.95 

Since it's all to do with the same database/site I'll ask it in this thread.

 

Is it possible to have a link/button on a website that tells the server to execute a batch file of some sort?

 

For my site I use Irfanview to convert PDFs to PNGs which are dumped in a certain folder, and I do this manually. After looking around it seems that you can run Irfanview from the command line with whatever switches you want, I'll have to look into what exactly I need, but only if it's worth doing.


0/0
 Reply   Quote More 

 From:  Drew (X3N0PH0N)  
 To:  ANT_THOMAS      
35356.96 In reply to 35356.95 
http://uk2.php.net/manual/en/function.exec.php

Not sure it whether works on windows.

0/0
 Reply   Quote More 

 From:  THERE IS NO GOD BUT (RENDLE)  
 To:  ANT_THOMAS      
35356.97 In reply to 35356.95 
If you're wanting to do image conversion, take a look at ImageMagick, for which there is a PHP PECL package.

0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  THERE IS NO GOD BUT (RENDLE)     
35356.98 In reply to 35356.97 
I shall take a look at that some point soon!

0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  ALL
35356.99 
Right, I have this code:

PHP code:
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ $prefixweb = "./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/";
    $prefixuni = "file:///N:/vol3/users/snmrdata/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/";
 
    echo " STUFF ";
}


I want to make it so when "machine" ({$row['machine']}) is a certain specific value, the value being "varian", the directory structures of $prefixweb and $prefixuni change.

If I'm thinking right I need to use an if else statement.

I've tried and failed as usual, hence the post.

I've concentrated on only one of the directory structures, $prefixuni, since that's the one I use the most.

So yeah, I've got this:

PHP code:
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{$prefixweb = "./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/";
 
if ($row['machine']=="varian")
{ 
$prefixuni = "file:///N:/vol3/users/snmrdata/{$row['year']}/service/{$row['month']}/4_StuYEAR/{$row['servercode']}/"
 
else 
 
$prefixuni = "file:///N:/vol3/users/snmrdata/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}";
}
    echo " STUFF ";
}


It don't work, why? :C


Also, can you have it try for a few different specifics then to go to a default?

As in

If A then 1 or
if B then 2 or
if C then 3
else 4

0/0
 Reply   Quote More 

 From:  steve  
 To:  ANT_THOMAS      
35356.100 In reply to 35356.99 
if (uh) {
something
}
else
{
something else
}

You have missed the closing }'s. Although that might not be the problem, as you've not mentioned the very obvious error that would come with that?

That might not even be PHP. I am late to thi thread. :C

0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  steve     
35356.101 In reply to 35356.100 
code:
Parse error: syntax error, unexpected T_ELSE in C:\wamp\www\full-iftest.php on line 41


After adding a } it still doesn't like it. Clearly has an issue with the else statement.

0/0
 Reply   Quote More 

 From:  dave (10_ROGUE)  
 To:  ANT_THOMAS      
35356.102 In reply to 35356.101 

What about the missing { before the else?

 

and by before I do ofcourse mean after.

0/0
 Reply   Quote More 

 From:  empathy  
 To:  ANT_THOMAS      
35356.103 In reply to 35356.101 
missing semicolon?
0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  empathy     
35356.104 In reply to 35356.103 
Possibly that! It works now :)

0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  ALL
35356.105 

Yay, another question, and most likely an easy one to answer. I am trying to make my thingy easier to make changes to in the future and because I am currently doing things in a retarded manner I want to change things.

 

I currently have a few separate pages/files to show entries in certain ways

 

full.php - standard single entry based on id
full5.php - as above but 5 entries
fullc.php - pulls single entry based on code
fullr.php - pulls single entry based on lab book ref

 

I realise this is very much the wrong way to do things, hence why I want to change it.

 

I currently decide things things based on using $_GET

 

.....php?id=xxx
.....php?code=ATxxx
.....php?ref=ATrxxx

 

I have easily got rid of the one to pull 5 entries so that's not a problem. I want to now combine all the others so I can for example use any of these:

 

full.php?id=xxx
full.php?code=ATxxx
full.php?ref=ATrxxx

 

I use these to get the values:

 

$tableid = $_GET['id'];
$tablecode = $_GET['code'];
$ref = $_GET['ref'];

 

But how do I now tell it to fetch the record based on which is actually present?

 

There will only ever be one of those there at any one time. I assume using some sort of if else null statements would sort it but I'm not sure how to go about it.


0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  ALL
35356.106 
Right, I think I may be somewhere along the right lines but it doesn't work...

I have :

PHP code:
 
$get = $_GET['get'];
 
if $get == ('AT###')
{$query  = "SELECT * FROM nmr WHERE code = $ref LIMIT $ent ";}
 
else if $get == ("ATr###")
{$query = "SELECT * FROM nmr WHERE labbookref = $ref ";}
 
else $get == ("###") 
{$query = "SELECT * FROM nmr WHERE id >= $ref LIMIT $ent ";}
 


$ent is just the number of entries to fetch.

$get is either going to be either of these

AT### - (code)
ATr### - (labbookref)
### - (id)

How? :C

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS      
35356.107 In reply to 35356.106 
You can use a regular expression to identify things.


Not sure if this is exactly right PHP syntax, but something along these lines should work...

php code:
preg_match ( /^(ATr?)?(.*)$/ , $get , $groups );
 
$ref= $groups[2];
 
$query = "SELECT * FROM nmr ";
 
switch( $groups[1] )
{
 
	case 'AT':
		$query .= "WHERE code = $ref";
	break;
 
	case 'ATr':
		$query .= "WHERE labbookref = $ref";	
	break;
 
	default:
		$query .= "WHERE id >= $ref";
	break;
}
 
$query .= "LIMIT $ent";
 
0/0
 Reply   Quote More 

 From:  ANT_THOMAS   
 To:  Peter (BOUGHTONP)     
35356.108 In reply to 35356.107 
Thank you for the reply.

I've managed to get it to work using what is probably an unorthadox way but it works :D


PHP code:
$get = $_GET['get'];
$ent= $_GET['ent']+1;
$grab = $_GET['grab'];
 
 
if ($get == "a")
{$query = "SELECT * FROM nmr WHERE id >= '$grab' LIMIT $ent ";}
 
if ($get == "b")
{$query  = "SELECT * FROM nmr WHERE code = '$grab' LIMIT $ent ";}
 
if ($get == "c")
{$query = "SELECT * FROM nmr WHERE labbookref = '$grab' ";}


Using a link along the lines of:

http://server/full.php?get=a&grab=25&ent=5

0/0
 Reply   Quote More 

Reply to All  
 

1–20  …  41–60  61–80  81–100  101–120  …  141–158

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats