PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
FREESTYLER
Forum Newbie
Posts: 17 Joined: Tue Oct 18, 2005 10:33 am
Post
by FREESTYLER » Wed Oct 19, 2005 12:15 pm
made my first project in php
actuly change it from java to php to run on our hosts site.
getting some errors
cant figure out why?
Heres the site
http://www.datainfinity.com/tmp/maplinks.php
and heres the code
line 50:
Code: Select all
if ($_GET['add'] == 'Add')
{
$insert =" INSERT INTO maplinks (name, url, description) " . " VALUES('" . $_GET['name'] . "','" . $_GET['url'] . "','" . $_GET['description'] . "') ";
$results=mysql_query($insert) or die('could not submit query ' . mysql_error());
}
lines 56, and 62 are the same with diffrent GET parameters (edit and delete)
i know this isnt the most efficent way but i started learning php last night.
thanks guys
Neill
Last edited by
FREESTYLER on Thu Oct 20, 2005 12:28 am, edited 1 time in total.
Ambush Commander
DevNet Master
Posts: 3698 Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US
Post
by Ambush Commander » Wed Oct 19, 2005 6:28 pm
You have E_ALL error reporting. Try making sure variables exist before trying to get their value.
Charles256
DevNet Resident
Posts: 1375 Joined: Fri Sep 16, 2005 9:06 pm
Post
by Charles256 » Wed Oct 19, 2005 6:33 pm
yeah,just do
Code: Select all
if (isset($variable)
{
pertinent code here
}
before you actually use every variable.that'll get rid of those notices:-D
Ambush Commander
DevNet Master
Posts: 3698 Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US
Post
by Ambush Commander » Wed Oct 19, 2005 6:35 pm
(missing parentheses)
Ternary operator is often quicker:
Code: Select all
$variable = isset($array['key']) ? $array['key'] : 'some default value';
Charles256
DevNet Resident
Posts: 1375 Joined: Fri Sep 16, 2005 9:06 pm
Post
by Charles256 » Wed Oct 19, 2005 6:36 pm
true but to me it's not nearly as readable...but that's just one of those personal preference things...
FREESTYLER
Forum Newbie
Posts: 17 Joined: Tue Oct 18, 2005 10:33 am
Post
by FREESTYLER » Wed Oct 19, 2005 11:59 pm
Charles256 wrote: yeah,just do
Code: Select all
if (isset($variable)
{
pertinent code here
}
before you actually use every variable.that'll get rid of those notices:-D
i tried this way and it got rid of my errors but also when i sent it a GET request it would not pick it up, so i couldnt add, edit or delete any of my entries?
Charles256
DevNet Resident
Posts: 1375 Joined: Fri Sep 16, 2005 9:06 pm
Post
by Charles256 » Thu Oct 20, 2005 12:16 am
actually do...
Code: Select all
if(isset($_REQUEST['variablename']))
{
blah
}
that should fix ya up
FREESTYLER
Forum Newbie
Posts: 17 Joined: Tue Oct 18, 2005 10:33 am
Post
by FREESTYLER » Thu Oct 20, 2005 12:28 am
Cheers Charles256
that fixed it up
thanks for your help