runnerjp Posted May 29, 2008 Share Posted May 29, 2008 im abit unsure where to put my brackets as my script does not seem to work where ever i put them i need to know the i finish the } for this part of the code <?php $query = "SELECT * FROM forumtutorial_posts where postid='$id'"; if ($result = mysql_query($query)){ if (mysql_num_rows($result)) { $array = mysql_fetch_assoc($result); $title = $array['title']; ?> <link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/css/login.css"> <link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/members/include/style.css"> <link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/css/login.css"><?php error_reporting(E_ALL); require_once '../settings.php'; checkLogin ('1'); $id=$_GET['id']; $query = "SELECT * FROM forumtutorial_posts where postid='$id'"; if ($result = mysql_query($query)){ if (mysql_num_rows($result)) { $array = mysql_fetch_assoc($result); $title = $array['title']; ?> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td class= width="30%" height="223" valign="middle" bgcolor="#FFFFFF"><p> </p> <p> </p></td> <td width="46%" valign="top" class= align="center" ><table class="headermenu" width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><? function error_bool($error, $field) { if($error[$field]) { print("<td style=color:red>"); } else { print("<td>"); } } function show_form() { global $HTTP_POST_VARS, $print_again, $error; ?> <form id="FormName" action='<?php "$_SERVER[php_SELF]" ?>' method="post" name="basic"> <table width="440" border="0" align="center" cellpadding="0" cellspacing="2"> <tr><td colspan="3" align="center" valign="middle"> <p align="center"><?php echo $title ?></p> </td> </tr> <tr> <td><div align="right"> <label for="dob">First name</label> </div></td> <td colspan="2"><input class="inputedit" id="title" name="title type="text" size="25" value="<?php echo $title;?>" maxlength="255" /></td> </tr> <tr> <td width="150" align="right">status</td> <td colspan="2"><? }function check_form() { global $HTTP_POST_VARS, $error, $print_again; $error['error'] = false; if (($_POST["title"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["title"]))) { $error['title'] = true; $print_again = true; $message = "The first name field is either empty or incorrect data was input.<br>"; } if($print_again) { show_form(); } else { show_form(); $message="<span class='style1'>Your profile has been created</span>"; $ $title = mysql_real_escape_string( $_POST['title']); $update = "UPDATE forumtutorial_posts SET title = '$title' WHERE postid='$id' "; $result = mysql_query($update); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result) { $er = 'Invalid query: ' . mysql_error() . "\n"; $er .= 'Whole query: ' . $query; die($er); }} echo ' <p class="error">' . $message . '</p>' . "\n"; } if(isset($_POST["basic"])) { check_form(); } else { show_form(); } ?></td> </tr> <tr> <td width="150"></td> <td width="112"><input name="basic" type="submit" class="submit-btn" value=""> </td> <td width="170"> </td> </tr> </table> </form></td> </tr> </table></td> <td width="24%" valign="middle" bgcolor="#FFFFFF"></td> </tr> <tr> <td colspan="3" valign="middle"></td> </tr> <tr> <td colspan="3"></td> </tr> <tr> <td colspan="3"></td> </tr> <tr> <td height="143" colspan="3"></td> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/107885-solved-where-to-put-my-brackets/ Share on other sites More sharing options...
runnerjp Posted May 29, 2008 Author Share Posted May 29, 2008 sorry sloppy coding didnt put <?php ?> satgs in makes it easyer for u guys <?php error_reporting(E_ALL); require_once '../settings.php'; checkLogin ('1'); $id=$_GET['id']; $query = "SELECT * FROM forumtutorial_posts where postid='$id'"; if ($result = mysql_query($query)){ if (mysql_num_rows($result)) { $array = mysql_fetch_assoc($result); $title = $array['title']; ?> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td class= width="30%" height="223" valign="middle" bgcolor="#FFFFFF"><p> </p> <p> </p></td> <td width="46%" valign="top" class= align="center" ><table class="headermenu" width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><?php function error_bool($error, $field) { if($error[$field]) { print("<td style=color:red>"); } else { print("<td>"); } } function show_form() { global $HTTP_POST_VARS, $print_again, $error; ?> <form id="FormName" action='<?php "$_SERVER[php_SELF]" ?>' method="post" name="basic"> <table width="440" border="0" align="center" cellpadding="0" cellspacing="2"> <tr><td colspan="3" align="center" valign="middle"> <p align="center"><?php echo $title ?></p> </td> </tr> <tr> <td><div align="right"> <label for="dob">First name</label> </div></td> <td colspan="2"><input class="inputedit" id="title" name="title type="text" size="25" value="<?php echo $title;?>" maxlength="255" /></td> </tr> <tr> <td width="150" align="right">status</td> <td colspan="2"><?php }function check_form() { global $HTTP_POST_VARS, $error, $print_again; $error['error'] = false; if (($_POST["title"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["title"]))) { $error['title'] = true; $print_again = true; $message = "The first name field is either empty or incorrect data was input.<br>"; } if($print_again) { show_form(); } else { show_form(); $message="<span class='style1'>Your profile has been created</span>"; $ $title = mysql_real_escape_string( $_POST['title']); $update = "UPDATE forumtutorial_posts SET title = '$title' WHERE postid='$id' "; $result = mysql_query($update); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result) { $er = 'Invalid query: ' . mysql_error() . "\n"; $er .= 'Whole query: ' . $query; die($er); }} echo ' <p class="error">' . $message . '</p>' . "\n"; } if(isset($_POST["basic"])) { check_form(); } else { show_form(); } ?> Link to comment https://forums.phpfreaks.com/topic/107885-solved-where-to-put-my-brackets/#findComment-553047 Share on other sites More sharing options...
Guardian-Mage Posted May 29, 2008 Share Posted May 29, 2008 <?php error_reporting(E_ALL); require_once '../settings.php'; checkLogin ('1'); $id=$_GET['id']; $query = "SELECT * FROM forumtutorial_posts where postid='$id'"; if ($result = mysql_query($query)){ if (mysql_num_rows($result)) { $array = mysql_fetch_assoc($result); $title = $array['title']; } //Closes if ($result = mysql_query($query)){ } //Closes if (mysql_num_rows($result)) { ?> Link to comment https://forums.phpfreaks.com/topic/107885-solved-where-to-put-my-brackets/#findComment-553052 Share on other sites More sharing options...
runnerjp Posted May 29, 2008 Author Share Posted May 29, 2008 but then i get Notice: Undefined variable: title on line 47 Link to comment https://forums.phpfreaks.com/topic/107885-solved-where-to-put-my-brackets/#findComment-553053 Share on other sites More sharing options...
AndyB Posted May 30, 2008 Share Posted May 30, 2008 but then i get Notice: Undefined variable: title on line 47 Whatever line 47 is. That's because ... the variable named title is undefined. It needs to exist before you can operate on it. Link to comment https://forums.phpfreaks.com/topic/107885-solved-where-to-put-my-brackets/#findComment-553101 Share on other sites More sharing options...
haku Posted May 30, 2008 Share Posted May 30, 2008 I prefer to use my braces like this, as it is very easy to see when one is missing: if(something) { foreach(something) { while(soemthing) { //do something } } } else { if(something) { // do something } } All braces are in line with each other. So to find missing braces, you just go vertically downwards from each brace and make sure it has a partner. Link to comment https://forums.phpfreaks.com/topic/107885-solved-where-to-put-my-brackets/#findComment-553188 Share on other sites More sharing options...
runnerjp Posted May 30, 2008 Author Share Posted May 30, 2008 ok got 1st bit working but when i post it i get status Notice: Undefined index: title in on line 63 which is this if (($_POST["title"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["title"]))) { $error['title'] = true; $print_again = true; $message = "The first name field is either empty or incorrect data was input.<br>"; } <?php error_reporting(E_ALL); require_once '../settings.php'; checkLogin ('1'); $id=$_GET['id']; $query = "SELECT * FROM forumtutorial_posts where postid='$id'"; if ($result = mysql_query($query)){ if (mysql_num_rows($result)) { $array = mysql_fetch_assoc($result); $title = $array['title']; ?> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td class= width="30%" height="223" valign="middle" bgcolor="#FFFFFF"><p> </p> <p> </p></td> <td width="46%" valign="top" class= align="center" ><table class="headermenu" width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><?php function error_bool($error, $field) { if($error[$field]) { print("<td style=color:red>"); } else { print("<td>"); } } function show_form() { global $HTTP_POST_VARS, $print_again, $error; ?> <form id="FormName" action='<?php "$_SERVER[php_SELF]" ?>' method="post" name="basic"> <table width="440" border="0" align="center" cellpadding="0" cellspacing="2"> <tr><td colspan="3" align="center" valign="middle"> <p align="center"><?}} ?></p> </td> </tr> <tr> <td><div align="right"> <label for="dob">First name</label> </div></td> <td colspan="2"><input class="inputedit" id="title" name="title type="text" size="25" value="<?php echo $title;?>" maxlength="255" /></td> </tr> <tr> <td width="150" align="right">status</td> <td colspan="2"><?php }function check_form() { global $HTTP_POST_VARS, $error, $print_again; $error['error'] = false; if (($_POST["title"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["title"]))) { $error['title'] = true; $print_again = true; $message = "The first name field is either empty or incorrect data was input.<br>"; } if($print_again) { show_form(); } else { show_form(); $message="<span class='style1'>Your profile has been created</span>"; $title = mysql_real_escape_string( $_POST['title']); $update = "UPDATE forumtutorial_posts SET title = '$title' WHERE postid='$id' "; $result = mysql_query($update); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result) { $er = 'Invalid query: ' . mysql_error() . "\n"; $er .= 'Whole query: ' . $query; die($er); }} echo ' <p class="error">' . $message . '</p>' . "\n"; } if(isset($_POST["basic"])) { check_form(); } else { show_form(); } ?> </table> Link to comment https://forums.phpfreaks.com/topic/107885-solved-where-to-put-my-brackets/#findComment-553312 Share on other sites More sharing options...
haku Posted May 30, 2008 Share Posted May 30, 2008 You should really start a new thread for new problems. But, your problem lies either in that $_POST['title'] doesn't exist (check that the name is right in your HTML) or that $error['title'] doesn't exist (I don't know where you have set that). You didn't tell us which line was line 63, so I don't know which of those two problems it is. Check line 63, and you will see one of the two variables I mentioned on that line. Find out why that isn't being set. Link to comment https://forums.phpfreaks.com/topic/107885-solved-where-to-put-my-brackets/#findComment-553333 Share on other sites More sharing options...
runnerjp Posted May 30, 2008 Author Share Posted May 30, 2008 humm ok its this line here if (($_POST["title"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["title"]))) butin my htl its set as this <td colspan="2"><input class="inputedit" id="title" name="title type="text" size="25" value="<?php echo $title;?>" maxlength="255" /></td> Link to comment https://forums.phpfreaks.com/topic/107885-solved-where-to-put-my-brackets/#findComment-553340 Share on other sites More sharing options...
haku Posted May 30, 2008 Share Posted May 30, 2008 Right now the name of your input isn't 'title'. It's 'title type='. Link to comment https://forums.phpfreaks.com/topic/107885-solved-where-to-put-my-brackets/#findComment-553506 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.